You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(mobile): localization infrastructure and language setting - #35399
First of a short series that localizes Orca Mobile. This PR adds the infrastructure and localizes Settings → Appearance; the following PRs move the rest of the app's strings over in batches, each with all ten translations.
Languages: the same 11 as desktop (en, zh, zh-Hant, ja, ko, es, fr, pt-BR, ru, tr, de), with the desktop's locale ids and terminology.
Choosing a language: Settings → Appearance → Language. System (default) follows the phone, including the per-app language in iOS Settings and Android 13+; the phone's whole preference list is walked, so Italian-then-Japanese gets Japanese. Any of the 11 can be picked instead. Switching is live, like the theme: navigation, scroll position and open terminals stay put.
Not following the paired desktop's language ([Feature]: Add i18n multi-language support to mobile app #8600 asked about this): a phone can pair with several desktops, a desktop's System means its own OS language, and older desktops don't report it. The phone's own choice covers the request.
Strings from the desktop (agent output, conversations, git output, host error text, push notification bodies, workspace status names) are shown as sent; mobile localizes only its own UI.
OTA pages (the screens the desktop serves to the phone) get the phone's language through a new optional uiLocale field in the bridge init frame, re-sent when it changes, the same way colorScheme works. Older shells send nothing and the page follows the WebView's language; older pages ignore the field; an unknown future locale is salvaged rather than refusing init.
Native strings: iOS permission prompts are localized through Expo locales; CFBundleLocalizations enables the iOS per-app language picker, CFBundleAllowMixedLocalizations keeps system UI in the device language, and a small config plugin declares Android 13+ locales_config (without the resource stripping the stock option adds). These need a native rebuild.
How it works
mobile/src/i18n/mobile-i18n.ts: i18next 26.5.11 with desktop's call shape, translate(key, englishFallback, options) and literal _one/_other plural families (reusing resolvePluralFamilyKey). load: 'currentOnly' so zh-Hant never falls back to Simplified, returnEmptyString: false, nesting disabled per call, catalogs installed with skipCopy, a bounded cache for option-free strings.
Catalogs live in mobile/src/i18n/locales/*.json (separate from desktop's 1.1 MB catalogs). English stays inline at call sites; only plural and non-literal entries ship eagerly (en-runtime-required.json, generated by the desktop generator). Other languages load through literal import(): Metro evaluates only the selected one, and the OTA page build emits one chunk per language, fetched only for the active one.
Language changes are latest-request-wins, fall back to English if a catalog fails, and finish under the splash at startup.
Components call const t = useMobileTranslation(); t changes identity with the language, so memos list it as a dependency. Helpers call translate() at the time text is shown.
Hermes has no Intl.PluralRules (nor Locale/RelativeTimeFormat); without it i18next picks _one for every count of 1 in every language and never Russian's few/many. The FormatJS polyfill is loaded with the 10 base languages' rules on native only (WebViews have it).
Dates and numbers go through getUiIntlLocale() (explicit pt-BR, zh-Hans/zh-Hant) instead of the platform default. Pages also set <html lang> so the WebView picks the right CJK glyphs.
Shared code: a part-based matchUiLocaleParts in src/shared/ui-locale.ts (desktop's matcher now calls it; Hermes has no Intl.Locale), native language names moved to src/shared/ui-language.ts, and pseudoLocalizeString gained an expand option (accents plus ~40% length) used by a development-only Pseudo language for truncation checks.
Gates
pnpm verify:mobile-localization (lint, check:changed, CI): reuses the desktop catalog verifier and runtime-catalog generator through a new --surface option, plus mobile checks: inline fallbacks match en.json, no unreferenced keys, every plural family has each CLDR category of its language, no translation at module scope or through the global translate() inside components/hooks, native locale lists match SUPPORTED_UI_LOCALES, and InfoPlist strings are complete and escape-safe.
pnpm verify:mobile-localization-coverage: the existing hardcoded-copy audit over mobile/app, mobile/src and mobile/web-entry with a baseline that the following PRs shrink. The audit now also reads accessibilityLabel/Hint and headerTitle; that surfaced six untranslated desktop screen-reader labels in worktree-palette-evidence.ts, added to the desktop baseline for a follow-up.
OTA bundle budget: language chunks get their own allowance (≤10 chunks, ≤3 MiB), like the terminal font, so code keeps its 9 MiB and route-chunk fences.
Bundle and startup
OTA page bundle: +55 KB entry (i18next; the plural polyfill is native-only), 1.50 MB before the first route vs. a 3 MiB budget. Catalog chunks are counted separately.
Native: i18next and the plural polyfill (~77 KB minified) load at startup; only English plurals plus the active language's catalog are evaluated.
Credit
This builds on the community work in #11587 by @Gyarados4157 (and #11446 by @brennanb2025 before it): the native InfoPlist approach, mixed localizations, running the coverage audit over the mobile tree, and keeping protocol sentinels and grouping identities separate from display text all come from there. Thank you both.
Validation
mobile typecheck and tests (i18n, bridge, settings, RPC recordings), verify:mobile-localization, both coverage audits, desktop localization script tests, build:mobile-web + bundle verification.
Translations for this PR's strings went through glossary-guided translation, placeholder/plural validation and two independent reviews per language.
Adds mobile language settings and localization support for Settings → Appearance.
Mobile Appearance now lets people pick an app language.
Desktop-served mobile pages follow the phone’s chosen language.
iOS and Android can offer Orca as a per-app language.
Mobile localization checks and bundle limits run in CI.
Desktop and mobile use the same language names and locale matcher.
No new findings were accepted. Review was source-only; tests and native UI checks were not run.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[Saved choice or device language] --> B[Resolve supported language]
B --> C[Load selected catalog]
C --> D[Update native text]
C --> E[Send uiLocale in bridge init]
E --> F[Load page catalog]
F --> G[Update page text and html lang]
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.
The change adds mobile UI localization across supported locales. It adds language preferences, translated appearance settings, localized iOS permission descriptions, and device-locale handling. The mobile shell passes the selected UI locale to the web page, which applies locale updates before rendering. Shared localization tools support desktop and mobile surfaces, and CI runs mobile localization and coverage checks. Mobile bundle checks account for locale catalog chunks separately.
Priority: Normal
Merge Risk: Moderate · previous review 0aa41
The localization sync command can remove translations needed for live counted text. Preserve referenced plural families before merging; the previously reported import and JSON-loading issues are fixed.
Pre-merge checks: 3 · 2
Failed checks: 2 warnings
Check name
Status
Explanation
Resolution
Description check
The description follows the repository template in substance. It has an ELI5-style Summary, a How it works section that explains the mechanism, and Gates and Validation sections that describe testing.…
Add a Visual Proof section with before and after screenshots or a video of Settings → Appearance → Language, or write N/A with a reason. Replace the 'Relates to' line with a 'Fixes #' issue link, or explain why no issue exists. Check the ma…
Docstring Coverage
Docstring coverage is 46.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta…
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 3 passed
Check name
Status
Explanation
Title check
The title "feat(mobile): localization infrastructure and language setting" matches the main change. The PR adds mobile i18n infrastructure, locale catalogs, native locale configuration, and a UI langu…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "feat(mobile): localization infrastructure and language setting" matches the main change. The PR adds mobile i18n infrastructure, locale catalogs, native locale configuration, and a UI language setting in Settings → Appearance, and the title names these directly. It is short and conventional-commit formatted, and it does not describe anything absent from the changeset.
Full details: Description check
Explanation
The description follows the repository template in substance. It has an ELI5-style Summary, a How it works section that explains the mechanism, and Gates and Validation sections that describe testing. The Why section is not labeled, but the Summary and How it works sections explain the alternatives and the reasoning, including why not to follow the paired desktop's language. The Linked Issue section is missing: the description says 'Relates to #8600, #9536, #31559' but has no 'Fixes #' or equivalent issue link. The Visual Proof section is missing: this is a UI change in Settings → Appearance, and the template requires before and after screenshots or video, or N/A with a reason. The Testing checkboxes, the AI Disclosure section, the Agent skill upstream boundary checkbox, and the Checklist are not filled in. Because the description covers the substance of the change and most required information, it is mostly complete. The missing Visual Proof and Linked Issue sections are the main gaps.
Resolution
Add a Visual Proof section with before and after screenshots or a video of Settings → Appearance → Language, or write N/A with a reason. Replace the 'Relates to' line with a 'Fixes #' issue link, or explain why no issue exists. Check the manual-testing and automated-test boxes, or explain their status. Fill in the AI Disclosure section, or leave it empty only if the author is a StablyAI team member. Complete the Review, Agent skill upstream boundary, and Checklist sections. Add a Why section that states the problem and the chosen approach against alternatives.
Full details: Docstring Coverage
Explanation
Docstring coverage is 46.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 60 functions across 48 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Finishing Touches: 💡 2
📝 Generate docstrings: 💡
Commit to this branch
Create a new PR
🛠️ Fix failing CI checks: 💡
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Major · Maintainability & Code Quality · Quick win
Use node: imports to pass the static-analysis gate.
The reported React Doctor gate rejects both changed built-in imports with unicorn/prefer-node-protocol. Use node:fs and node:path so this validation workflow can pass.
Proposed fix
--- "a/mobile/plugins/android-locale-config.js"+++ "b/mobile/plugins/android-locale-config.js"@@ -1,5 +1,5 @@-const fs = require('fs')-const path = require('path')+const fs = require('node:fs')+const path = require('node:path')
const { withAndroidManifest, withDangerousMod, AndroidConfig } = require('expo/config-plugins')
// Declares the Android 13+ per-app language list. expo-localization's own Android option also
Committable suggestion
IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
Suggested change
constfs=require('fs')
constpath=require('path')
constfs=require('node:fs')
constpath=require('node:path')
Tools
GitHub Actions: PR 35399 | source 094f034 | workflow 094f034 | unit full / 15_static analysis and typecheck.txt
[error] 1-1: React Doctor changed-lines gate failed: unicorn/prefer-node-protocol — use the node: protocol when importing Node.js built-in modules.
[error] 2-2: React Doctor changed-lines gate failed: unicorn/prefer-node-protocol — use the node: protocol when importing Node.js built-in modules.
GitHub Actions: PR 35399 | source 094f034 | workflow 094f034 | unit full / static analysis and typecheck
[error] 1-1: React Doctor changed-lines gate failed: unicorn/prefer-node-protocol — Prefer using the node: protocol when importing Node.js built-in modules. Command: node config/scripts/check-react-doctor-changed.mjs "93ff4832e463421a5dc3d08295364439ab50bad9".
[error] 2-2: React Doctor changed-lines gate failed: unicorn/prefer-node-protocol — Prefer using the node: protocol when importing Node.js built-in modules. Command: node config/scripts/check-react-doctor-changed.mjs "93ff4832e463421a5dc3d08295364439ab50bad9".
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
Mark JSON modules as ES modules in the custom loader.
TypeScript 6.0.3 routes both dynamic and static JSON imports through the supplied require callback. The current JSON result lacks __esModule, so the interop helpers wrap it and module.default becomes { default: parsed } instead of the parsed catalog.
Suggested JSON module shape
--- "a/mobile/src/test-support/rpc-recording/operation-module-loader.ts"+++ "b/mobile/src/test-support/rpc-recording/operation-module-loader.ts"@@ -63,10 +63,13 @@
}
)
}
if (name.endsWith('.json')) {
// Catalogs and other data modules carry no behavior; hand over their parsed value.
- return { default: JSON.parse(readFileSync(resolve(dirname(base), name), 'utf8')) }+ return {+ __esModule: true,+ default: JSON.parse(readFileSync(resolve(dirname(base), name), 'utf8'))+ }
}
const file = pathFor(resolve(dirname(base), name))
if (file === sharedModulePath) {
return deliveryAmbiguity
Add a regression test for a dynamic JSON import.
Committable suggestion
IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
Suggested change
if(name.endsWith('.json')){
// Catalogs and other data modules carry no behavior; hand over their parsed value.
The reason will be displayed to describe this comment to others. Learn more.
Named helpers escape the check
runsAfterRender now treats every named local function except render* as a handler. A component containing const label = () => translate('a.b', 'Hello') and rendering label() therefore passes the check, even though the helper runs during render. Previously, the check reached the enclosing component and reported it.
This weakens the development check: labels without a language subscription can stay in the old language. Keep checking named synchronous helpers unless their use shows that they run after render.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
Keep a plural sibling while its family is referenced.
A counted call such as translate('items_one', fallback, { count }) names only items_one. At runtime, resolvePluralFamilyKey strips the suffix to items, so counts other than one need items_other. The stale-key check still reports items_other as unreferenced, because it looks only for the base name items, which no call names. With --fix, pruneCatalogKeys then removes items_other from every catalog, including en.json. The family check at line 324 does not protect it. That check only controls whether locale-only forms are removed.
Treat any referenced plural form as proof that the family is live. Apply that rule to both the stale-key report and the --fix pruning input:
Suggested fix
const result = compareExtraction(nestCatalog(extracted), englishCatalog)
- const unreferenced = findUnreferencedKeys(result.orphans, result.extracted, keyEvidence)+ // A plural family is live when any form is named; its other forms still resolve at runtime.+ const liveFamilies = new Set(+ [...references.map((reference) => reference.key), ...keyEvidence.literals]+ .map((key) => PLURAL_SUFFIX_RE.exec(key)?.[1])+ .filter(Boolean)+ )+ const unreferenced = findUnreferencedKeys(result.orphans, result.extracted, keyEvidence).filter(+ (key) => !liveFamilies.has(PLURAL_SUFFIX_RE.exec(key)?.[1])+ )
Mobile follows the phone's language (or an in-app choice under Settings > Appearance)
across the same 11 languages as desktop, switching live like the theme does.
- i18next with desktop's translate(key, fallback, options) call shape; catalogs in
mobile/src/i18n/locales load lazily, English fallbacks stay inline
- Hermes lacks Intl.PluralRules: load the FormatJS polyfill with the 11 languages' rules
- OTA pages get the shell's language through an optional bridge init field
- iOS permission prompts localized; iOS and Android 13+ per-app language pickers
- verify:mobile-localization and a coverage ratchet run in lint, check:changed and CI
…ocalization gates
- Wait for the latest page language activation, not a superseded one
- Keep literal fallbacks when a key also has a dynamic one
- Count headerTitle as visible copy; select the mobile check when the runtime catalog generator changes
Components that read the theme already subscribe for repaint; a language switch
repaints them too, so labels built by helpers during render follow it. RPC
recordings load the real i18next and JSON catalogs.
…rune stale keys on sync
Handlers and effects may call translate() when they run. sync:mobile-localization now
removes keys no code references from every catalog.
…ed plural siblings on prune
Also let anonymous default-exported screens count as components, flag any plural
family a locale started, and mark JSON modules as ES modules in the recording loader.
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
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.
Summary
First of a short series that localizes Orca Mobile. This PR adds the infrastructure and localizes Settings → Appearance; the following PRs move the rest of the app's strings over in batches, each with all ten translations.
uiLocalefield in the bridgeinitframe, re-sent when it changes, the same waycolorSchemeworks. Older shells send nothing and the page follows the WebView's language; older pages ignore the field; an unknown future locale is salvaged rather than refusing init.locales;CFBundleLocalizationsenables the iOS per-app language picker,CFBundleAllowMixedLocalizationskeeps system UI in the device language, and a small config plugin declares Android 13+locales_config(without the resource stripping the stock option adds). These need a native rebuild.How it works
mobile/src/i18n/mobile-i18n.ts: i18next 26.5.11 with desktop's call shape,translate(key, englishFallback, options)and literal_one/_otherplural families (reusingresolvePluralFamilyKey).load: 'currentOnly'so zh-Hant never falls back to Simplified,returnEmptyString: false, nesting disabled per call, catalogs installed withskipCopy, a bounded cache for option-free strings.mobile/src/i18n/locales/*.json(separate from desktop's 1.1 MB catalogs). English stays inline at call sites; only plural and non-literal entries ship eagerly (en-runtime-required.json, generated by the desktop generator). Other languages load through literalimport(): Metro evaluates only the selected one, and the OTA page build emits one chunk per language, fetched only for the active one.const t = useMobileTranslation();tchanges identity with the language, so memos list it as a dependency. Helpers calltranslate()at the time text is shown.Intl.PluralRules(norLocale/RelativeTimeFormat); without it i18next picks_onefor every count of 1 in every language and never Russian's few/many. The FormatJS polyfill is loaded with the 10 base languages' rules on native only (WebViews have it).getUiIntlLocale()(explicitpt-BR,zh-Hans/zh-Hant) instead of the platform default. Pages also set<html lang>so the WebView picks the right CJK glyphs.matchUiLocalePartsinsrc/shared/ui-locale.ts(desktop's matcher now calls it; Hermes has noIntl.Locale), native language names moved tosrc/shared/ui-language.ts, andpseudoLocalizeStringgained anexpandoption (accents plus ~40% length) used by a development-only Pseudo language for truncation checks.Gates
pnpm verify:mobile-localization(lint,check:changed, CI): reuses the desktop catalog verifier and runtime-catalog generator through a new--surfaceoption, plus mobile checks: inline fallbacks matchen.json, no unreferenced keys, every plural family has each CLDR category of its language, no translation at module scope or through the globaltranslate()inside components/hooks, native locale lists matchSUPPORTED_UI_LOCALES, and InfoPlist strings are complete and escape-safe.pnpm verify:mobile-localization-coverage: the existing hardcoded-copy audit overmobile/app,mobile/srcandmobile/web-entrywith a baseline that the following PRs shrink. The audit now also readsaccessibilityLabel/HintandheaderTitle; that surfaced six untranslated desktop screen-reader labels inworktree-palette-evidence.ts, added to the desktop baseline for a follow-up.Bundle and startup
Credit
This builds on the community work in #11587 by @Gyarados4157 (and #11446 by @brennanb2025 before it): the native InfoPlist approach, mixed localizations, running the coverage audit over the mobile tree, and keeping protocol sentinels and grouping identities separate from display text all come from there. Thank you both.
Validation
mobiletypecheck and tests (i18n, bridge, settings, RPC recordings),verify:mobile-localization, both coverage audits, desktop localization script tests,build:mobile-web+ bundle verification.Relates to #8600, #9536, #31559.