Repository navigation
feat(i18n): add Brazilian Portuguese locale and fall back to English - #780
Merged
Merged
Conversation
Add a full pt-BR dictionary to the hub panel and stop resolving unsupported
host locales to Chinese.
- locales: new `pt` dictionary, one-to-one with the `en` keys (452 entries),
including the dynamic failKind_/failReason_ pairs and every {placeholder}.
- useLanguage: language selection moves to `dictKeyOf` / `nextLocaleOf`.
Previously every host locale other than `en` resolved to `zh`, so pt, ja,
de, fr and ru users got the Chinese interface; unknown locales now fall
back to English and the header toggle cycles en -> zh -> pt.
- category labels, Intl date formatting and the remote about / changelog
content prefer English (not Chinese) when the UI language is not zh.
- server catalog and install error messages: non-zh locales receive English
text instead of Chinese.
- tests: key parity and failKind_/failReason_ pairing are enforced for all
three dictionaries, pt is checked for leftover CJK text, and the locale
fallback rules have their own unit tests.
The toggle label was derived from the zh URL prefix, so with three languages it always read 中文 — including for pt users, whose next stop is English. The label now comes from the same cycle the toggle actually uses.
dshplugin
pushed a commit
that referenced
this pull request
Nov 14, 2026
The pt dictionary added by #780 could never become active: the host only ships zh and en, so setLocale('pt') threw "locale is not registered" on the second toggle press. Register the language definition first, ignore the duplicate-registration error when another pack already owns pt, and map region-qualified ids (pt-BR, zh-CN) back to their dictionary.
Collaborator
|
Merged — thanks, the fallback direction was genuinely wrong and this fixes a bug we had not caught. One follow-up was needed after merge, in
|
Collaborator
|
Merged — thanks, the fallback direction was genuinely wrong and this fixes a bug we had not caught. One follow-up was needed after merge, in
|
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Adds a Brazilian Portuguese (
pt) dictionary to the hub panel and fixes the language fallback that made every non-English host locale render Chinese.Why
useLanguageresolved the dictionary withlang === 'en' ? 'en' : 'zh', so a host running in Portuguese (or Japanese, German, French, Russian, Spanish) received thezhdictionary — the hub was either English or Chinese, never anything else. The hub is used from a pt-BR host, which is how this showed up.Changes
ptdictionary, one to one with theenkeys (452 entries), keeping every{placeholder}and the dynamicfailKind_*/failReason_*pairs.src/client/logic/locale-key.ts):dictKeyOf()maps the host locale to a shipped dictionary — unknown locales fall back to English, not Chinese — andnextLocaleOf()cyclesen → zh → ptfor the header toggle.CATEGORY_LABELS/CATEGORY_SHORT_LABELScarryptnow, and their type isRecord<LocaleId, string>instead of{ zh, en }.intlLocaleOf()inlogic/format.ts; absolute dates usept-BRinstead of falling back tozh-CN.{ zh, en }, so non-zh locales now prefereninstead ofzh.catalog(which catalog file to fetch) andinstall(error messages) now treat every locale other thanzhas English. Server-side messages are still zh/en only — a pt version of those two strings would be a separate change if you want it.failKind_*/failReason_*pairing are enforced across all three dictionaries,ptis asserted free of leftover CJK, andlocale-keyhas its own unit tests for the fallback and the toggle order.Verification
npm run check(typecheck client+server+test,node --test, build) passes locally: 268 tests, 0 failures. Builtclient/client.jsandlib/are included in the commit, per the repo's practice of committing build output.Notes / open questions
pt: that is what the host reports, sopt-BRis not registered separately.Follow-up in this branch
中文, even for pt users whose next stop is English. It now comes from the same cycle the toggle uses (logic/locale-key.ts).