Repository navigation
feat(i18n): follow the OS language when no language is selected - #168
Open
devs-rootstrap wants to merge 2 commits into
Open
devs-rootstrap wants to merge 2 commits into
devs-rootstrap wants to merge 2 commits into
Conversation
devs-rootstrap
requested review from
amaury901130,
asdolo and
fernandatoledo
and
a balanced review from Copilot
November 9, 2026 12:07
💯 Test Coverage
😎 Tests Results
👀 Tests Details • (57%)
|
There was a problem hiding this comment.
🟡 Changes recommended
Foreground language synchronization leaves existing labels in the previous language because Text does not react to language changes and its translation cache is not language-scoped.
1 open issue
What changed in this PR
Overall Review: ai:serious
This PR extends the template’s localization support to follow OS language changes while preserving explicit in-app language selections.
Changes:
- Prioritizes the saved language at startup, falling back to the OS locale.
- Adds foreground language synchronization with lifecycle-managed listener cleanup.
- Adds initialization and synchronization tests, plus documentation of the behavior and RTL limitation.
| File | Description |
|---|---|
src/lib/i18n/utils.tsx |
Adds language resolution and foreground synchronization helpers. |
src/lib/i18n/index.tsx |
Uses saved-language precedence during initialization. |
src/app/_layout.tsx |
Mounts the synchronization hook once at the root. |
docs/src/content/docs/guides/internationalization.mdx |
Documents OS language tracking and the RTL restart requirement. |
__tests__/lib/i18n/sync-language-with-os.test.ts |
Tests language precedence, foreground updates, and listener cleanup. |
__tests__/lib/i18n/index.test.ts |
Tests startup language selection. |
Review effort: Balanced
fernandatoledo
approved these changes
Nov 16, 2026
fernandatoledo
enabled auto-merge
November 16, 2026 19:46
amaury901130
approved these changes
Nov 19, 2026
This branch has not been deployed
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.

Jira board reference:
What does this do?
The app language now follows the OS language unless a language was selected in the app.
getLanguage() ?? getLocales()[0]?.languageTag). Before this changesrc/lib/i18n/index.tsxonly used the OS locale and ignored the stored selection.src/lib/i18n/utils.tsx:getDeviceLanguage(),resolveLanguage()andsyncLanguageWithOS().useSyncLanguageWithOS()hook, mounted once insrc/app/_layout.tsx. It listens toAppStatechanges and, when the app becomesactiveand no language was selected in the app, re-reads the OS locale withexpo-localizationand calls i18next'schangeLanguageif it differs from the current language. The app's ownchangeLanguageutil (which reloads/restarts the app) is not used here.Follows up on the discussion in #77.
Why did you do this?
As raised in #77, i18n is only initialized once, so if the OS language changes while the app is in the background, the app keeps the old language until it is restarted. Expo recommends listening to app state changes and reading the locales again (docs). Changing the language through i18next directly re-renders the translated UI without restarting the app.
Who/what does this impact?
Layer 2: Risk Classification
Author applies a risk label when opening the PR. When in doubt, escalate.
risk:lowrisk:mediumrisk:highSetup
risk:low,risk:medium,risk:highlabels in the repoHow did you test this?
Unit tests added in
__tests__/lib/i18n/:index.test.ts: the stored language wins at startup; the OS locale is used when nothing is stored.sync-language-with-os.test.ts:resolveLanguageprecedence; the foreground update only happens when nothing is stored and the OS locale changed; no update onbackground; theAppStatelistener is removed on unmount.How to test locally
git checkout feat/sync-language-with-ospnpm installpnpm testpnpm iosorpnpm android) without selecting a language in Settings.src/lib/i18n/resources.tshave translations; others fall back toen).Notes:
Assumptions
en-US) is passed to i18next as is, matching the previous startup behavior; i18next resolves it to the closest available resource withenas fallback.Known limitations
I18nManageris only configured at startup, so switching between LTR and RTL OS languages while the app is running takes effect after a restart.translate()helper are cached per key and are not refreshed when the language changes at runtime; components usinguseTranslation()or theTexttxprop update immediately.Verification
pnpm lint: passedpnpm type-check: passedpnpm lint:translations: passedpnpm test: 30 suites, 151 tests passedScreenshots / Previews
Not applicable (no UI changes).