feat(i18n): ship CJK and FIGS locales alongside English - #178
Closed
iAstro wants to merge 2 commits into
Closed
Conversation
The extension ships en-US and zh-CN resources, but only en-US was ever
selected: every other browser language fell through to fallbackLng
("zh-CN"), so users on en, en-GB, en-CN, en-AU, ja-JP, fr-FR saw Chinese.
Match on the BCP 47 language subtag and normalise it to a resource key:
en* -> en-US
zh-Hans* / zh-CN / zh-SG / zh -> zh-CN
zh-Hant* / zh-TW / zh-HK / zh-MO -> zh-TW
anything else -> unchanged (fallbackLng default: en-US)
Simplified vs Traditional is decided by the script subtag (Hans/Hant) when
present, then by the region subtag, since Chrome reports zh-CN / zh-TW
rather than script subtags. The zh-TW branch is written now so adding a
Traditional translation later needs no code change.
chrome.i18n.getUILanguage() is now preferred over navigator.language, which
is unreliable on the chrome-extension:// origin the popup runs on.
Adds a locale-resolution regression matrix (28 cases).
Closes Tencent#168
Adds seven translated bundles — zh-TW, ja, ko, fr, it, de, es — so the UI follows the browser language across major markets instead of falling back to Chinese (Tencent#168) or, after Tencent#174, to English only. Resource keys use bare language subtags (ja, ko, fr, it, de, es) so regional variants share one bundle: fr-CA, fr-BE and fr all resolve to fr. Chinese stays split by script, zh-CN / zh-TW, because Simplified and Traditional differ by script rather than by region. normalizeLanguageCode now resolves every shipped language from a single map, and fallbackLng gained a per-language chain: fallbackLng: { en: [en-US], zh: [zh-CN], ja: [ja], ko: [ko], fr: [fr], it: [it], de: [de], es: [es], default: [en-US] } so an untranslated locale still lands on English rather than Chinese. Tests grow from 28 to 80 cases. Besides the expanded resolution table, the bundles are now checked structurally: every locale must expose the same key set as en-US, keep identical {{placeholders}} (a dropped one renders as a blank gap), leave no key empty, and leave the product and brand name untranslated. Built on top of Tencent#174. Closes Tencent#168
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 this adds
Seven translated bundles on top of the existing English and Simplified Chinese:
zh-TW,ja,ko,fr,it,de,es. The UI now follows the browser language across the major markets instead of falling back to Chinese (#168) or, after #174, to English only.Resource keys
Bare language subtags for the new languages, so regional variants share one bundle:
en*en-USzh-Hans*,zh-CN,zh-SG,zhzh-CNzh-Hant*,zh-TW,zh-HK,zh-MOzh-TWja,ja-JPjako,ko-KRkofr,fr-FR,fr-CAfrit,it-ITitde,de-DE,de-ATdees,es-ES,es-MXesChinese stays split by script (
zh-CN/zh-TW) because Simplified and Traditional differ by script rather than by region.Fallback chain
An untranslated locale (
pt-BR,ru-RU, ...) still lands on English rather than Chinese.Tests
28 -> 80 cases. Beyond the expanded resolution table, the bundles are checked structurally - every locale must:
en-US(catches a missing or leftover key){{placeholders}}(a dropped one renders as a blank gap)browser-skill/BrowserSkilluntranslatedNotes for reviewers
daemon,protocol,instance IDandtraceare kept consistent across languages. ThestateBadgevalues (Standby/Igniting/Ready/Off) stay in English, matching the deliberate choice already made in the zh-CN bundle.Closes #168