Skip to content

Commit

Permalink
Document how to prevent i18next-parser translation overrides (#451)
Browse files Browse the repository at this point in the history
  • Loading branch information
jgonggrijp committed May 2, 2022
1 parent a6a9e83 commit 34900a9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,15 @@ yarn i18next -c i18next-parser.config.mjs

The files thus produced can be sent to the translators in order to fill out the actual translations.

Defaults sometimes start or end with spaces. `i18next` will strip them, but in some cases they need to be retained. The following trick will preserve those spaces and prevent `i18next` from stripping them again in the future:

1. Manually edit `src/i18n/en/translation.json` to put the spaces back and commit.
2. Run `i18next` to autogenerate the translation files. This will strip the spaces from the `translation.json` that you just hand-edited in. However, a copy of your hand-edited strings is retained in `src/i18n/en/translation_old.json`.
3. Run `git checkout HEAD src/i18n/en/translation.json` to restore your hand-edited strings in the main `translation.json` as well.
4. Commit the `translation_old.json`. Because both the `translation.json` and the `translation_old.json` contain your hand-edited version of the string, `i18next` will remember not to strip the spaces again in the future.

The above trick can also be used in other situations where you want to prevent `i18next` from overriding what is in the `translation.json`, for example if you decide to remove a default value from the source files altogether.


#### Adding new languages

Expand Down

0 comments on commit 34900a9

Please sign in to comment.