feat: Add i18n for tanstack start - #762
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7d45285ba7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const redirectTo = localeRouting.redirectPathnameFor(pathname) | ||
| if (redirectTo !== undefined) { |
There was a problem hiding this comment.
Preserve the locale when issuing canonical redirects
When a locale-prefixed request itself requires a redirect, this early return bypasses the later cookie logic. For example, a first-time Polish visitor requesting /pl/admin is redirected to /admin without a vitnode_locale=pl cookie, so the destination resolves to English; similarly, /en does not replace an existing Polish preference. Attach the explicit source locale's cookie to the redirect response before returning.
Useful? React with 👍 / 👎.
| * `invalidate()` then re-runs the matched routes. Two reasons: the internal URL | ||
| * did not change, so nothing looks stale to the router even though every loader | ||
| * that read `context.locale` now holds the previous answer - and on an ignored | ||
| * route such as `/admin`, where the URL does not change at all, it is the whole |
There was a problem hiding this comment.
Prevent stale language switches from winning
If a visitor selects two languages quickly, each invocation waits independently for its message request before navigating. A slow first selection can therefore complete after a faster second selection and overwrite the URL with the language the visitor no longer chose; the cookie, written immediately by the second selection, can then disagree with the rendered locale. Serialize switches or discard a completion when it is no longer the latest request.
Useful? React with 👍 / 👎.
| const requested = normalizeNamespaces(namespaces) | ||
|
|
||
| if (requested.length > MAX_NAMESPACES) { |
There was a problem hiding this comment.
Reject oversized namespace arrays before normalizing them
For a public server-function request containing a very large namespace array, normalization constructs a Set and sorts the values before the 16-item limit is checked. Arrays containing thousands of repeated names also normalize below the limit and are accepted, defeating the stated bound while still consuming work and memory. Validate the raw array's length before de-duplication and sorting.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d1e61056ef
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| locales: i18n.locales | ||
| .filter(locale => locale.enabled !== false) | ||
| .map(locale => locale.code), |
There was a problem hiding this comment.
Reject a disabled default locale
When the locale marked as defaultLocale also has enabled: false, this filter removes it from the supported set while preserving it as the default. The resulting router can return a locale for which isSupportedLocale is false; with localePrefix: "always", it also leaves / unprefixed because prefixFor(defaultLocale) treats the default as unsupported. Since VitNodeI18nConfig permits this configuration, either retain the default locale or reject the configuration explicitly.
Useful? React with 👍 / 👎.
Improving Documentation
pnpm lint:fixto fix formatting issues before opening the PR.Description
What?
Why?