Skip to content

Working with I18N

Paul Girard edited this page Jul 13, 2023 · 9 revisions

We use react-i18n to handle text translation is the application. Locale files are under the directory src/locales.

Dev process

dev.json is the only file you should modify. When you dev you have to add your keys in it, and that's all.

If you forgot to add your keys, you can run npm run translations-scan. This will add all the missing keys in the dev.json

NOTE: In dev mode, the "Dev langage" is available in the lang selector.

Weblate integration

We use weblate to manage the tanslation of Gephi-lite : https://hosted.weblate.org/projects/gephi/gephi-lite Weblate has a direct access to the repository, and when a new key is added to the dev.json file, it will discovered.

If a translation is added or changed on the weblate interface, you have to commit it on the weblate interface, and then to push it. This will create a commit on the weblate-i18n branch of gephi-lite and create a pull request.

Weblate only modify local files (ie. not the dev.json), so we should not have conflict on this branch.

Git weblate

Weblate is using git with the code source of the project :

$> git remote add weblate https://hosted.weblate.org/git/gephi/gephi-lite/ 
$> git remote update weblate
$> git switch -c weblate-dev weblate/dev

Lifecycle

(Dev) -[UPDATE]-> (`src/locale/dev.json`) <-[READ]- (Weblate) -[WRITE]-> (`src/locale/{locale}.json`) 
  • Weblate rebase its dev branch with the dev one of the project.
  • We you do modification on the interface, weblate commit to its dev branch
  • Every day, if there is an update, weblate push into weblate-i18n on github, and do a PR

FAQ

How to add a new locale

On weblate, a user can create a new locale and work on the translation, and then a new locale file in the project will be available.

To enable this new locale in the application you have to define it in the file https://github.com/gephi/gephi-lite/blob/dev/src/locales/locales.ts

How to solve conflict

  • Add locally the dev branch of weblate (see the Git weblate section)
  • Update the branch : (weblate-dev $)> git pull
  • Go on the dev branch : (weblate-dev $)> git checkout dev
  • Rebase the weblate-dev branch into the dev one : git rebase weblate-dev

That's all folks.

How to solve same translation issue for en language

The en language is very often just a copy of the dev language which is prefilled with english language.

Thus Weblate throws lot of warning for same translations.

To remove those warning in bulk: