Skip to content

[wallet/symbol/mobile] fix: localization mess - #2571

Open
OlegMakarenko wants to merge 9 commits into
devfrom
wallet/locale
Open

OlegMakarenko wants to merge 9 commits into
devfrom
wallet/locale

Conversation

@OlegMakarenko

@OlegMakarenko OlegMakarenko commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Problem

English (en.json) is the only locale file that feeds the UI with up-to-date text, and it degraded over time:

  • Many unused localization keys that were never cleaned up. Some of them even from the Opt-in era.
  • No naming rules at all - key structure and format were inconsistent, several conventions mixed together.
  • Some texts duplicated under different keys.
  • Raw error code strings and raw numeric transaction type descriptors were passed straight to the translation layer.
  • The other language files were not updated for a long time - keys and translations are outdated.

Solution

1. Localization guidelines

Researched, finalized and committed as wallet/symbol/mobile/docs/localization.md. The core rules:

  • Keys are flat: segments joined with _, camelCase inside a segment.
  • After the scope prefix, a key is a chain of element–name pairs:
    <element>_<name>[_<element>[_<name>]], at most 7 segments in total.
Scope Pattern Example
Global <element>_<name>… button_ok
Screen screen_<folder>[_<section>]_… screen_bridge_swap_dialog_confirm_title
Component component_<componentName>_… component_navigationMenu_tab_home
  • Element words come from a fixed vocabulary (button, dialog, title, fieldTitle, errorMessage, …); names are free camelCase words chosen by meaning.
  • Always pick the widest scope that fits; never duplicate a text under a narrower key.
  • Keys are literal strings - no building keys from variables, except a few registered runtime builders and mapper tables.
  • Placeholders use one format: %{name}.

2. en.json cleanup

  • Analyzed key usage across the app; removed unused keys.
  • Removed duplications.
  • Renamed all keys to follow the new pattern and rules; sorted the file alphabetically.
  • Proofread the English texts: fixed grammar, typos, and unified template placeholders.

3. Mapper functions (src/utils/localization.js)

  • Errors: every error now has its own key in the locale file, and getErrorMessageLocaleKey(code) maps error codes to those keys — no more raw code strings passed to the translation function. Unknown codes fall back to a generic message.
  • Transaction types: getTransactionTypeLocaleKey(type, chainName, direction) maps the raw chain-specific numeric descriptors to human-readable locale keys (and getReceiptTypeLocaleKey does the same for receipt types).

4. Test system enforcing the guidelines (3 files)

File What it enforces
__tests__/localization/en-json.test.js File format (sorted keys, no duplicates, canonical formatting). Every key follows the pattern structure, element words come from the whitelist, and scopes are real: the test reads the actual src/screens and src/components directories and rejects keys pointing to a screen or component that does not exist.
__tests__/localization/translations.test.js Each registered translation file has exactly the same keys as en.json, no extra keys, and the same key order. A registry check ensures every file in the locales directory is consciously listed.
__tests__/utils/localization.test.js Input/output tests for the error, transaction type and receipt type mappers, plus a completeness check that every mapper output is an existing en.json key.

5. Usage updates

  • All UI code and the existing tests were updated to use the renamed keys.

The other locale files (cn/ja/ko/uk/zh) are kept temporarily to reuse texts from; they will be rewritten from scratch separately and added to the consistency test one by one as they land.

@codecov

codecov Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.93685% with 65 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.19%. Comparing base (c50933c) to head (b8088a7).
⚠️ Report is 2 commits behind head on dev.

Files with missing lines Patch % Lines
...rc/screens/bridge/components/EstimationSummary.jsx 73.68% 15 Missing ⚠️
...reens/bridge/hooks/useBridgeTransactionWorkflow.js 87.35% 11 Missing ⚠️
...ile/src/screens/bridge/components/SwapSelector.jsx 87.03% 7 Missing ⚠️
wallet/symbol/mobile/src/localization/index.js 60.00% 6 Missing ⚠️
.../src/app/components/NetworkConnectionStatusBar.jsx 20.00% 4 Missing ⚠️
...le/src/screens/mosaic/components/InputDuration.jsx 66.66% 4 Missing ⚠️
...et/symbol/mobile/src/screens/bridge/BridgeSwap.jsx 97.67% 2 Missing ⚠️
...le/src/screens/multisig/widgets/MultisigWidget.jsx 0.00% 2 Missing ⚠️
...bol/mobile/src/components/controls/InputAmount.jsx 66.66% 1 Missing ⚠️
...rc/components/display/Token/ExpirationProgress.jsx 50.00% 0 Missing and 1 partial ⚠️
... and 12 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##              dev    #2571      +/-   ##
==========================================
+ Coverage   95.83%   96.19%   +0.35%     
==========================================
  Files         786      744      -42     
  Lines       60742    56625    -4117     
  Branches     1696     1665      -31     
==========================================
- Hits        58214    54469    -3745     
+ Misses       2460     2089     -371     
+ Partials       68       67       -1     
Flag Coverage Δ
explorer-puller ?
explorer-rest ?
wallet-common-ethereum 99.11% <ø> (ø)
wallet-mobile-symbol 95.53% <96.93%> (+1.15%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ymbol/mobile/src/app/components/NavigationMenu.jsx 84.61% <100.00%> (-1.93%) ⬇️
...bol/mobile/src/components/controls/FeeSelector.jsx 94.89% <100.00%> (ø)
...bol/mobile/src/components/controls/SelectToken.jsx 100.00% <100.00%> (ø)
...rc/components/controls/SelectTransactionSender.jsx 92.89% <100.00%> (ø)
...mbol/mobile/src/components/display/MessageView.jsx 100.00% <100.00%> (ø)
...e/src/components/display/Token/TokenBalanceRow.jsx 100.00% <100.00%> (ø)
...ile/src/components/display/Token/TokenListItem.jsx 100.00% <100.00%> (ø)
...ents/features/Passcode/hooks/usePasscodeManager.js 96.02% <100.00%> (+0.56%) ⬆️
...le/src/components/features/Passcode/utils/index.js 84.48% <100.00%> (ø)
...ile/src/components/features/SendReceiveButtons.jsx 98.92% <100.00%> (ø)
... and 118 more

... and 47 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@OlegMakarenko
OlegMakarenko marked this pull request as ready for review September 18, 2026 15:16
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