perf: Refactor internationalization support with locale files in plugins#726
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: 81cc497143
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3eb5c66823
ℹ️ 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".
| "@vitnode/core": () => import("./locales/@vitnode/core/pl.json"), | ||
| "@vitnode/blog": () => import("./locales/@vitnode/blog/pl.json"), |
There was a problem hiding this comment.
Add JSON import attributes to API-compatible loaders
When this documented shared config is used by a standalone API built with tsc and run under the repository's supported Node ESM environment, these imports throw ERR_IMPORT_ATTRIBUTE_MISSING because JSON modules require { with: { type: "json" } }. loadSourceMessages catches that error, so requests and emails silently lose the configured Polish overrides and fall back to default messages. Add the import attributes here, as the plugin locale example already does.
Useful? React with 👍 / 👎.
| locale: string; | ||
| sources: MessagesSource[]; | ||
| }): Promise<Messages> => { | ||
| const cacheKey = `${defaultLocale}|${locale}|${sources.map(source => source.id).join(",")}`; |
There was a problem hiding this comment.
Include source identity in the message cache key
When two VitNode configurations run in one process with the same locale and plugin IDs but different loaders or app overrides—for example, two mounted Hono apps—their cache keys are identical. Whichever configuration loads first therefore supplies its message tree to the other configuration, potentially serving the wrong app's copy; key this cache by the source-array or loader identity rather than only the source IDs.
Useful? React with 👍 / 👎.
| const locales = [ | ||
| ...new Set([...declared, ...appFiles.map(file => file.locale)]), | ||
| ].filter(locale => locale !== defaultLocale); |
There was a problem hiding this comment.
Discover package locales before checking translations
For the supported API-only setup with no i18n block, runtime locales are derived from every installed package's message map, but this checker derives extra locales only from declared config and app-owned files. If a plugin ships an incomplete pl.json, vitnode i18n:check --ci reports that there are no extra locales and exits successfully even though the API exposes Polish at runtime; include locale files discovered from the installed packages in this union.
Useful? React with 👍 / 👎.
Improving Documentation
pnpm lint:fixto fix formatting issues before opening the PR.Description
What?
Why?