Skip to content

perf: Refactor internationalization support with locale files in plugins#726

Merged
aXenDeveloper merged 2 commits into
canaryfrom
refactor/i18n
Jul 25, 2026
Merged

perf: Refactor internationalization support with locale files in plugins#726
aXenDeveloper merged 2 commits into
canaryfrom
refactor/i18n

Conversation

@aXenDeveloper

Copy link
Copy Markdown
Owner

Improving Documentation

Description

What?

Why?

@vercel

vercel Bot commented Jul 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
vitnode-docs Ready Ready Preview, Comment Jul 25, 2026 4:02pm

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread packages/vitnode/src/api/models/email.ts Outdated
@aXenDeveloper
aXenDeveloper merged commit dae5d4a into canary Jul 25, 2026
4 checks passed
@aXenDeveloper
aXenDeveloper deleted the refactor/i18n branch July 25, 2026 16:05

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +64 to +65
"@vitnode/core": () => import("./locales/@vitnode/core/pl.json"),
"@vitnode/blog": () => import("./locales/@vitnode/blog/pl.json"),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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(",")}`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment on lines +90 to +92
const locales = [
...new Set([...declared, ...appFiles.map(file => file.locale)]),
].filter(locale => locale !== defaultLocale);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🚀 Performerce Improves performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant