Translations
The project uses the library Lingui to translate the application and Crowdin to allow anybody to help translating the application.
Messages format
Messages in the Electron renderer process (UI/React) use the Gettext format (.po
files) while messages in the Electron main process use a JSON format with explicit IDs.
While it would be better to use the Gettext format everywhere, we use a JSON format for the main electron process for the following reasons:
- Dynamic import of JS modules on Windows doesn't work when the file is located inside an Electron ASAR archive (at least when I tried it)
- We would have to do the compile step manually (
.po
to.js
files) - There are a few translations in the main process (tray icon, file menu...)
Crowdin synchronization
To keep in sync the repository with Crowdin translations, we use the Crowdin GitHub action.
It allows us to create a PR per language with latest translations done by translators and upload new translations to Crowdin based on the application source code.
- Translations are uploaded when something is pushed to the
main
branch. - Translations are downloaded from Crowdin every 12 hours.
Workflows can also be triggered manually from GitHub but it's possible only from maintainers.
Adding a new language
Developer or maintainer steps
- The first step is to find the locale code.
A locale code usually contains the language and optionally a region (country) separated by an underscore or dash character (example:en-US
for English spoken in the United States).
Languages may have multiple regions (en-US
,en-GB
,en-CA
...).
In most cases the differences are mainly in spelling or vocabulary that doesn't prevent people from different regions to understand each other.
Because of that, we usually use the language code without the region when possible.
You can find all locale codes here.
If the local code contains only a language, you can use it as is.
If the locale code contains the langage and the region, you have to decide if using only the language code is enough.
For example, there are many regions for English (en-US
,en-GB
,en-CA
...) but the application only support one English languageen
because the differences are not significant enough to justify multiple languages.
At the opposite, the localeszh-CN
andzh-TW
are very different and we support both of them. - Add the code in the UI Lingui config and main process Lingui config
- Add the code in the GitHub action matrix
- Add the code in the UI select options
- Add support for the language in the function
getFnsLocale
of the date picker component - If the locale is composed of the language + region (example:
zh-CN
) add a mapping in the Crowdin conf - Create a PR
Maintainer steps
The following steps can be done only by a project maintainer.
- Go on Crowdin
- Add the new language from the dashboard
- Trigger a new Download translations job
- A new PR with new language files should have been created, review it and merge it