Repository navigation
[i18n] Show backend messages in the CLI's language (issues#3157) - #59
Merged
Merged
Conversation
…3157) haxcms-nodejs responses now carry a `code` and `params` next to their English message. The CLI translates them with the same locales/haxcms-api.<lang>.json files the editor uses (bundled with haxcms-nodejs), and falls back to the server's English message. - src/lib/api-messages.js: apiMessage(body, fallback) and annotateApiBody(), which adds codes to bodies from routes the CLI calls in-process when the installed haxcms-nodejs supports them (no-op before). - i18n.js: translateOnly() (a translation in the current language, or null so callers can keep more specific English) and hasNamespace(). - site.js: node:add failures, site export failures and import failures use the translated message. Import failures used to be silent and leave an empty site; they now warn with the reason. - Two new strings (siteExportFailed, siteImportFailed) in all 102 languages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EN4mJgNh8uj2C44jDs4KAD
Contributor
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of haxtheweb/issues#3157. Merge last. It needs a haxcms-nodejs release that has
dist/lib/apiMessageCodes.jsand bundles the webcomponents build withhaxcms-elements/locales/haxcms-api.*.json(haxtheweb/webcomponents#883). Until then it is a safe no-op: you get the English messages, as now.What it touches
src/lib/api-messages.js(new):apiMessage(body, fallback)translates bycodeusing the locale files bundled with haxcms-nodejs (bundledElementLocales('haxcms-elements')), the same text the editor shows. Otherwise it falls back to the server's English message.annotateApiBody()adds codes to bodies from routes the CLI calls in-process (invokeRoute), using haxcms-nodejs's own matcher.src/lib/i18n.js:translateOnly(): returns the current language's text ornull, so callers can keep more specific English.hasNamespace().site.js:node:addfailures show the translated reason.t('siteExportFailed', {reason})instead of an English log line holding raw JSON.t('siteImportFailed', {source, reason}).siteExportFailed,siteImportFailed) in all 102 languages. They pass the coverage test andvalidate_lang.Tests
test/unit/api-messages.test.cjs: envelope shapes, English vs. translated, missing params, unknown codes, and the annotate no-op with an older haxcms-nodejs.npm test: 380 pass, 0 fail.Generated by Claude Code