Skip to content

feat(mobile): localization infrastructure and language setting - #35399

Merged
OrcaWin merged 10 commits into
mainfrom
OrcaWin/mobile-i18n-1
Oct 29, 2026
Merged

OrcaWin merged 10 commits into
mainfrom
OrcaWin/mobile-i18n-1

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​196 $\color{#cf222e}{\Huge{\mathbf{−}}}$​7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​189
Prod 72 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​14142 $\color{#cf222e}{\Huge{\mathbf{−}}}$​191 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​13951

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.

  • 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.

Relates to #8600, #9536, #31559.

@OrcaWin
OrcaWin requested a review from brennanb2025 as a code owner October 28, 2026 21:51
@greptile-apps

greptile-apps Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with the existing non-blocking named-helper check issue still open.

Findings

  1. P2 Named helpers escape the check ▶

Summary

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]
Loading

Reviews (9) · Last reviewed commit: "chore(mobile): refresh the localization ..." · Reviewed by Greptile

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

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.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
Walkthrough

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: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Description check Warning 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 Warning 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 Passed checks: 3 passed
Check name Status Explanation
Title check Passed 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 Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 37558a80-bff4-4b66-8dee-47ed2913ffe6
Commits

Reviewing files that changed from the base of the PR and between 93ff483 and 64d571b.

Files ignored due to path filters: 1
  • mobile/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
Files selected for processing: 74
  • .github/workflows/pr.yml
  • config/localization-coverage-allowlist.json
  • config/mobile-localization-coverage-allowlist.json
  • config/scripts/audit-localization-coverage.mjs
  • config/scripts/build-mobile-web-app-bundle.mjs
  • config/scripts/build-mobile-web-app-bundle.test.mjs
  • config/scripts/check-changed-selection.mjs
  • config/scripts/generate-runtime-required-english-catalog.mjs
  • config/scripts/localization-surfaces.mjs
  • config/scripts/run-lint.mjs
  • config/scripts/verify-localization-catalog.mjs
  • config/scripts/verify-mobile-localization.mjs
  • config/scripts/verify-mobile-localization.test.mjs
  • config/scripts/verify-mobile-web-app-bundle.mjs
  • mobile/README.md
  • mobile/app.json
  • mobile/app/_layout.tsx
  • mobile/locales/de.json
  • mobile/locales/en.json
  • mobile/locales/es.json
  • mobile/locales/fr.json
  • mobile/locales/ja.json
  • mobile/locales/ko.json
  • mobile/locales/pt-BR.json
  • mobile/locales/ru.json
  • mobile/locales/tr.json
  • mobile/locales/zh-Hans.json
  • mobile/locales/zh-Hant.json
  • mobile/package.json
  • mobile/plugins/android-locale-config.js
  • mobile/src/i18n/en-runtime-required.json
  • mobile/src/i18n/locale-catalog-imports.ts
  • mobile/src/i18n/locales/de.json
  • mobile/src/i18n/locales/en.json
  • mobile/src/i18n/locales/es.json
  • mobile/src/i18n/locales/fr.json
  • mobile/src/i18n/locales/ja.json
  • mobile/src/i18n/locales/ko.json
  • mobile/src/i18n/locales/pt.json
  • mobile/src/i18n/locales/ru.json
  • mobile/src/i18n/locales/tr.json
  • mobile/src/i18n/locales/zh-Hant.json
  • mobile/src/i18n/locales/zh.json
  • mobile/src/i18n/mobile-i18n.test.ts
  • mobile/src/i18n/mobile-i18n.ts
  • mobile/src/i18n/plural-rules-polyfill.ts
  • mobile/src/i18n/plural-rules-polyfill.web.ts
  • mobile/src/i18n/system-ui-locale.test.ts
  • mobile/src/i18n/system-ui-locale.ts
  • mobile/src/i18n/ui-intl-locale.ts
  • mobile/src/i18n/ui-language-preference.ts
  • mobile/src/i18n/use-follow-device-ui-locale.ts
  • mobile/src/i18n/use-mobile-translation.ts
  • mobile/src/mobile-web-shell/MobileWebShellScreen.tsx
  • mobile/src/mobile-web-shell/bridge-host-contract.ts
  • mobile/src/mobile-web-shell/bridge-host-route.ts
  • mobile/src/mobile-web-shell/bridge-host.ts
  • mobile/src/mobile-web-shell/bridge/bridge-client-session.ts
  • mobile/src/mobile-web-shell/bridge/bridge-client-shell-session.ts
  • mobile/src/mobile-web-shell/bridge/bridge-envelope.ts
  • mobile/src/mobile-web-shell/bridge/bridge-init-frame.ts
  • mobile/src/mobile-web-shell/bridge/bridge-rpc-client-frames.test.ts
  • mobile/src/mobile-web-shell/bridge/bridge-rpc-client.ts
  • mobile/src/mobile-web-shell/bridge/bridge-ui-locale.test.ts
  • mobile/src/mobile-web-shell/use-mobile-web-shell-bridge.ts
  • mobile/src/settings/appearance-settings-screen.tsx
  • mobile/src/settings/appearance-settings-styles.ts
  • mobile/src/settings/ui-language-settings-section.tsx
  • mobile/web-entry/index.tsx
  • package.json
  • src/renderer/src/i18n/supported-languages.ts
  • src/shared/pseudo-localization.ts
  • src/shared/ui-language.ts
  • src/shared/ui-locale.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

Comment thread mobile/plugins/android-locale-config.js Outdated
Comment on lines +1 to +2
const fs = require('fs')
const path = require('path')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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
const fs = require('fs')
const path = require('path')
const fs = require('node:fs')
const path = 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".

Source: Pipeline failures

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: dbacfc94-aeca-4474-bc13-05c25336846e
Commits

Reviewing files that changed from the base of the PR and between 64d571b and 1d629a1.

Files selected for processing: 5
  • config/scripts/verify-mobile-localization.mjs
  • config/scripts/verify-mobile-localization.test.mjs
  • mobile/src/test-support/rpc-recording/native-mounting-substitutes.ts
  • mobile/src/test-support/rpc-recording/operation-module-loader.ts
  • mobile/src/theme/use-mobile-color-scheme.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

Comment on lines +66 to +69
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')) }
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Major · Functional Correctness · Quick win

Supported by static analysis

Script executed:

set -eu
printf '%s\n' '--- changed files ---'
git diff --stat be7a6eecc777293fc1142c6aeb94b83397a1bda8 1d629a1fc800f80b9f5dfd09883e15be38e8dee8 -- mobile/src/test-support/rpc-recording/operation-module-loader.ts mobile/src/test-support/rpc-recording/compiled-operation-module.ts mobile/src/test-support/rpc-recording/locale-catalog-imports.ts mobile/src/i18n/mobile-i18n.ts mobile/package.json
printf '%s\n' '--- loader at head ---'
git show 1d629a1fc800f80b9f5dfd09883e15be38e8dee8:mobile/src/test-support/rpc-recording/operation-module-loader.ts | nl -ba
printf '%s\n' '--- compiled module at head ---'
git show 1d629a1fc800f80b9f5dfd09883e15be38e8dee8:mobile/src/test-support/rpc-recording/compiled-operation-module.ts | nl -ba
printf '%s\n' '--- JSON import references ---'
git grep -n -E 'import\\([^)]*\\.json|\\.json.*import|module\\.default|operationModuleLoader|compiledOperationModule' 1d629a1fc800f80b9f5dfd09883e15be38e8dee8 -- mobile/src mobile/package.json || true
printf '%s\n' '--- package and compiler configuration ---'
git show 1d629a1fc800f80b9f5dfd09883e15be38e8dee8:mobile/package.json | nl -ba
find mobile -maxdepth 3 -type f \\( -name 'tsconfig*.json' -o -name '*operation*module*' -o -name '*loader*test*' \\) -print
printf '%s\n' '--- available TypeScript package metadata ---'
find . -path '*/node_modules/typescript/package.json' -o -path '*/node_modules/typescript-api/package.json' | head -20 | while read f; do echo "$f"; cat "$f"; done

Repository: stablyai/orca

Length of output: 16058


Script executed:

set -eu
printf '%s\n' '--- changed files ---'
git diff --stat be7a6eecc777293fc1142c6aeb94b83397a1bda8 1d629a1fc800f80b9f5dfd09883e15be38e8dee8 -- mobile/src/test-support/rpc-recording/operation-module-loader.ts mobile/src/test-support/rpc-recording/compiled-operation-module.ts mobile/src/test-support/rpc-recording/locale-catalog-imports.ts mobile/src/i18n/mobile-i18n.ts mobile/package.json
printf '%s\n' '--- loader at head ---'
git show 1d629a1fc800f80b9f5dfd09883e15be38e8dee8:mobile/src/test-support/rpc-recording/operation-module-loader.ts | nl -ba
printf '%s\n' '--- compiled module at head ---'
git show 1d629a1fc800f80b9f5dfd09883e15be38e8dee8:mobile/src/test-support/rpc-recording/compiled-operation-module.ts | nl -ba
printf '%s\n' '--- JSON import references ---'
git grep -n -E 'import\\([^)]*\\.json|\\.json.*import|module\\.default|operationModuleLoader|compiledOperationModule' 1d629a1fc800f80b9f5dfd09883e15be38e8dee8 -- mobile/src mobile/package.json || true
printf '%s\n' '--- package and compiler configuration ---'
git show 1d629a1fc800f80b9f5dfd09883e15be38e8dee8:mobile/package.json | nl -ba
find mobile -maxdepth 4 -type f \( -name 'tsconfig*.json' -o -name '*operation*module*' -o -name '*loader*test*' \) -print
printf '%s\n' '--- available TypeScript package metadata ---'
find . \( -path '*/node_modules/typescript/package.json' -o -path '*/node_modules/typescript-api/package.json' \) -print | head -20 | while read f; do echo "$f"; cat "$f"; done

Repository: stablyai/orca

Length of output: 23391


Script executed:

set -eu
printf '%s\n' '--- JSON and loader references ---'
for pattern in 'import(' '.json' 'module.default' 'operationModuleLoader' 'compiledOperationModule'; do
  echo "### $pattern"
  git grep -n -F -- "$pattern" 1d629a1fc800f80b9f5dfd09883e15be38e8dee8 -- mobile/src mobile/package.json || true
done
printf '%s\n' '--- loader tests ---'
git show 1d629a1fc800f80b9f5dfd09883e15be38e8dee8:mobile/src/test-support/rpc-recording/operation-module-loader.test.ts | nl -ba
printf '%s\n' '--- i18n caller files ---'
for f in mobile/src/i18n/mobile-i18n.ts mobile/src/test-support/rpc-recording/locale-catalog-imports.ts; do
  if git cat-file -e 1d629a1fc800f80b9f5dfd09883e15be38e8dee8:"$f" 2>/dev/null; then
    echo "### $f"
    git show 1d629a1fc800f80b9f5dfd09883e15be38e8dee8:"$f" | nl -ba
  fi
done
printf '%s\n' '--- TypeScript 6.0.3 synthetic emit ---'
node <<'JS'
const ts = require('./node_modules/.pnpm/[email protected]/node_modules/typescript/lib/typescript.js')
for (const [name, source] of [
  ['dynamic', 'export async function load() { return (await import("./catalog.json")).default }'],
  ['static', 'import catalog from "./catalog.json"; export function load() { return catalog }'],
  ['namespace', 'import * as catalog from "./catalog.json"; export function load() { return catalog.default }'],
]) {
  const out = ts.transpileModule(source, {
    compilerOptions: {
      module: ts.ModuleKind.CommonJS,
      target: ts.ScriptTarget.ES2022,
      resolveJsonModule: true,
      esModuleInterop: true,
    },
    fileName: `${name}.ts`,
  }).outputText
  console.log(`### ${name}`)
  console.log(out)
}
JS

Repository: stablyai/orca

Length of output: 45667


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.
return { default: JSON.parse(readFileSync(resolve(dirname(base), name), 'utf8')) }
}
if (name.endsWith('.json')) {
// Catalogs and other data modules carry no behavior; hand over their parsed value.
return {
__esModule: true,
default: JSON.parse(readFileSync(resolve(dirname(base), name), 'utf8'))
}
}

@OrcaWin
OrcaWin force-pushed the OrcaWin/mobile-i18n-1 branch from a76e7bb to a6ed0d6 Compare October 28, 2026 22:29
Comment on lines +185 to +193
// Named local functions are callbacks unless they are render helpers (`renderRow`).
const name = ts.isFunctionDeclaration(fn)
? fn.name?.text
: (ts.isPropertyAssignment(parent) || ts.isVariableDeclaration(parent)) &&
ts.isIdentifier(parent.name)
? parent.name.text
: undefined
if (name !== undefined) {
return !/^render/i.test(name)

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8be1a710-21ef-4b90-8870-4bea73da7008
Commits

Reviewing files that changed from the base of the PR and between a6ed0d6 and 0aa4191.

Files selected for processing: 3
  • config/scripts/verify-mobile-localization.mjs
  • config/scripts/verify-mobile-localization.test.mjs
  • mobile/src/test-support/rpc-recording/operation-module-loader.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

.filter(
(family) =>
family &&
[...english.keys()].every((key) => familyOf(key) !== family || keys.includes(key))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Major · Data Integrity & Integration · Quick win

Supported by static analysis

Script executed:

sed -n '90,135p;310,340p' config/scripts/verify-mobile-localization.mjs
rg -n 'findUnreferencedKeys|familyOf|plural|count' mobile/src/i18n/mobile-i18n.ts config/scripts/verify-localization-extraction.mjs config/scripts/verify-mobile-localization.mjs | head -100

Repository: stablyai/orca

Length of output: 5850


Script executed:

cat -n config/scripts/verify-localization-extraction.mjs | sed -n '60,140p'
cat -n src/shared/i18n-plural-family.ts
cat -n mobile/src/i18n/mobile-i18n.ts | sed -n '1,90p'
rg -n -F --glob '*.{ts,tsx,mjs}' -e 'resolvePluralFamilyKey' -e 'i18n-plural-family' -- mobile src config || test "$?" -eq 1

Repository: stablyai/orca

Length of output: 9288


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])
+  )

@OrcaWin
OrcaWin force-pushed the OrcaWin/mobile-i18n-1 branch from 0aa4191 to 5a0d609 Compare October 28, 2026 23:09
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant