Skip to content

i18n with Translatewiki

benoit74 edited this page Oct 10, 2025 · 3 revisions

Our tools, both scrapers and frontends of user-facing applications like Zimit-frontend, needs to be internationalized for easier access.

To manage the translation work, we use TranslateWiki project, which is a collective effort to build a free and open translation community on top of a Mediawiki.

This work needs to be incorporated in our codebase and the standard way of doing so is:

  • We define a file-format and data structure in our code repository to host translation
  • TranslateWiki configure a sub-project per repository we wanna translate to plug its tooling
  • Translators create/update translations on TranslateWiki interface
  • TranslateWiki pushes pull-requests with translators work
  • We review and merge this work

File format and data structure

Default file format is JSON files, with one JSON file per language (including one special 'qqq' language), named <lang_code>.json

Default structure is one folder at the root of the repository with all JSON files.

Structure of the JSON file itself is "free-form". The @metadata key is reserved for TranslateWiki usage. We recommend to have a semi-structured keys approach, grouping similar stuff under the same parent key for readability / usability.

Before contacting TranslateWiki:

  • this structure must be created with at least en.json and qqq.json
  • code must use these files to display labels, ...
  • code must be ready to add new languages

Configuration in TranslateWiki

Requirements and process to join TranslateWiki are documented at https://translatewiki.net/wiki/Translating:New_project

The core of the process consist in creating a Phabricator ticket with all required information.

Since we already have a "parent project", we simply want them to create a new sub-project which is kinda more simple.

Parent project: Kiwix

Do not forget to add the affects-Kiwix-and-openZIM tag.

Use in Python project

Zimit-frontend

In zimit-frontend, we use the python-i18n package to source JSON files but it is abandoned (see https://github.com/openzim/zimit-frontend/issues/173).

See e.g. API codebase for usage.

Gutenberg

In Gutenberg, we use the i18nice package to source JSON files.

See e.g. gutenberg codebase for usage.

Use in Vue.JS projects

Zimit-frontend

In zimit-frontend we used vue-i18n package to load JSON files, fallback, ...

See e.g. zimit-frontend codebase for usage.

CI Checks

Zimit-frontend has a nice CI job to check consistency of translations: see check-i18n job in QA workflow.

Clone this wiki locally