Skip to content

fix(i18n): stop double-escaping interpolated values and clean up i18n keys - #1541

Merged
theborakompanioni merged 6 commits into
joinmarket-webui:develfrom
bhuvan-somisetty:i18n/cleanup-dead-keys
Nov 2, 2026
Merged

theborakompanioni merged 6 commits into
joinmarket-webui:develfrom
bhuvan-somisetty:i18n/cleanup-dead-keys

Conversation

@bhuvan-somisetty

@bhuvan-somisetty bhuvan-somisetty commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

1. Bug fix: interpolated values were HTML-escaped twice (fix(i18n) commit)

i18next escapes interpolated values by default, and React escapes rendered text again. Anything with ', /, &, < or " in a {{ value }} came out as entities, e.g. log search, error reasons in toasts and alerts. This sets interpolation.escapeValue: false, which is what react-i18next recommends. I checked that no translated text is rendered as raw HTML (no dangerouslySetInnerHTML anywhere in src).

2. Cleanup: open i18n TODOs and stale keys (chore(i18n) commit)

  • Sidebar trigger: dedicated open/close titles (was undefined while collapsed)
  • BranchEntryTable: own jar_details.address_list.* keys instead of borrowing the UTXO list ones
  • Moved shared keys to global (copied-address toast used by 4 components, jar badge label). Existing translations were carried over, so nothing falls back to English
  • minimum_makers error toast: reason passed as a param instead of string concatenation
  • Removed 5 unused keys from all locales, and 44 keys from the translated locales that no longer exist in en. Keys used via $t() nesting were kept; I checked each one
  • Added src/i18n/locales.test.ts, which fails if a $t() nested reference doesn't resolve, a locale has keys missing in en, or a translation uses an interpolation variable en doesn't know

3. Locales out of sync with en (fix(i18n): keep variables... commit, added 10-22)

The locales test now also fails if a translation drops a variable of the en string, uses different <Trans> components, or misses a plural form its language needs (per Intl.PluralRules). Fixed what it found:

  • de/it/pt-BR/ru/zh-Hans/zh-Hant dropped the reason from the fee config loading error
  • de showed the wrong nested hint (and count) in the scheduler confirmations hint
  • fr dropped the fee from the absolute fee label and rendered stray <0> tags in the lock wallet modal
  • ru had no few/many forms, so e.g. 3 or 5 entries fell back to English ("3 entries"); now "3 записи", "5 записей"
  • it/pt-BR had no many forms (only used for large numbers like 1 000 000)

Rebased onto devel; the rescan shortcut buttons were dropped from this PR since devel already localized them.

The first commit is independent of the rest, so I can split it into a separate PR if you prefer.

Sweep form strings are left out on purpose; they are covered in #1533.

Testing

  • npx vitest run --project unit: 1143 tests, all pass (one ImportDetailsForm test timed out once under full-suite load on my machine and passes on its own)
  • tsc -b, eslint and prettier --check are clean.

Visual Demo (For contributors especially)

Image Demo (if applicable):

Real LogViewer in Storybook (en), searching for won't connect:

Before After
before after

Comment thread src/i18n/locales/en/translation.json Resolved
@bhuvan-somisetty

Copy link
Copy Markdown
Contributor Author

rebased and added one more commit: the locale test now also checks that translations keep the en variables, Trans tags and plural forms. it caught a few real ones, e.g. ru showed "3 entries" in english because the few/many forms were missing. fixed all of them, details in the description

i18next escapes interpolated values by default. React escapes rendered
text on its own, so values were escaped twice and entities showed up in
the UI, e.g. searching the logs for "won't" displayed
`No matches for "won&joinmarket-webui#39;t".` and error reasons containing `/`, `'` or
`&` were mangled in toasts and alerts.

Disable `interpolation.escapeValue`, as recommended for react-i18next.
No translated text is rendered as raw HTML.

Signed-off-by: bhuvan-somisetty <somisettybhuvan5@gmail.com>
- localize the rescan shortcut buttons and the segwit activation tooltip
- add distinct titles for the sidebar trigger (open/close)
- give the branch address table its own keys and an index column label
- move shared keys (copied address toast, jar badge label) to `global`
- pass the reason as a param in the `minimum_makers` error toast
- rename the `defaultValue` interpolation param, which collides with an
  i18next option, to `defaultPercentage`
- remove 5 unused keys from all locales and 42 stale keys from the
  translated locales that no longer exist in the source language
- add tests that guard nested `$t()` references, orphaned keys and
  unknown interpolation variables across all locales

Signed-off-by: bhuvan-somisetty <somisettybhuvan5@gmail.com>
Signed-off-by: bhuvan-somisetty <somisettybhuvan5@gmail.com>
Extends the locales test to also check that translations
- keep every interpolation variable of the source string (except count)
- use the same <Trans> components as the source string
- contain every plural form their language needs (per Intl.PluralRules)

and fixes what it found:
- de/it/pt-BR/ru/zh-Hans/zh-Hant dropped the reason from the fee config
  loading error
- de showed the "fund wallet" hint with the wrong count in the scheduler
  confirmations hint
- fr dropped the fee from the absolute fee label and rendered stray <0>
  tags in the lock wallet modal
- ru had no few/many forms, so e.g. "3 entries" was shown in English
- it/pt-BR had no many forms (only used for large numbers)

Signed-off-by: bhuvan-somisetty <somisettybhuvan5@gmail.com>
bhuvan-somisetty and others added 2 commits October 31, 2026 15:18
…keys

Signed-off-by: bhuvan-somisetty <somisettybhuvan5@gmail.com>

# Conflicts:
#	src/i18n/locales/de/translation.json
@theborakompanioni
theborakompanioni merged commit 110794b into joinmarket-webui:devel Nov 2, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cleanup i18n Issues related to translation and internationalisation (i18n)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Interpolated i18n values are HTML-escaped twice (e.g. won&#39;t)

2 participants