Mobileraker already supports multiple languages, but it relies on contributions to add new languages and keep existing translations up to date. If you want to add your own language or update an existing one, please feel free to open a Pull Request (PR). This guide provides details on the structure of translation keys and how to add a new language.
This section outlines the format of the translation files and keys.
All available language files can be found in the assets/translations
directory. Each file adheres to the BCP 47 (IETF
language tag) standard, consisting of a language code (e.g., 'en' for English, 'de' for German) and, if necessary, a
region or country code (e.g., 'zh-CN' for Chinese in mainland China, 'zh-HK' for Chinese in Hong Kong). These language
files are in JSON format to organize the translations efficiently.
Within each file, key-value pairs are used for translation. The value associated with each key can be either another collection of key-value pairs or a string that contains the translation. To translate a file, you only need to modify the string values.
String values can take several forms:
-
Simple Text: For example,
"translation_key": "I am a text to translate."
-
Text with Arguments: For example,
"translation_key": "I am a text to translate in language {}."
-
Text with Linked Translations: For example,
"translation_key": "@:example.hello User! How are you?"
. This means an already defined key is used within this new translation. In the example,example.hello
refers to another translation. -
Text with Linked Translations and a Modifier: For example,
"translation_key": "@:example.hello:capitalize User! How are you?"
. Here, a linked translation is used, and a modifier (in this case,:capitalize
) is applied to the text.
To add a new and currently unsupported translation, please follow these steps:
- Clone the repository.
- Make a copy of the
en.json
file and rename it in compliance with the BCP 47 (IETF language tag) standard. - Remove the sections
"languages" : {...
from the copied file, as this section should not be translated and should only be present in theen.json
file. - Translate either all or some of the values in the new language file.
- Add the new language to the lib/main.dart file in the following section.
...return EasyLocalization(
supportedLocales: const [
Locale('af'),
Locale('de'),
Locale('en'),
Locale('fr'),
Locale('hu'),
Locale('it'),
Locale('nl'),
Locale('ro'),
Locale('ru'),
Locale('uk'),
Locale('zh', 'CN'),
Locale('zh', 'HK'),
],
...
- Add yourself to the contributors list in this file.
- Create a Pull Request (PR).
To edit an existing language file, follow these steps:
- Clone the repository.
- Make your desired changes in the language file.
- Add yourself to the contributors list in this file.
- Create a Pull Request (PR).
- 🇿🇦 Afrikaans, @DMT07
- 🇭🇰 Chinese Hong Kong, @old-cookie
- 🇨🇳 Chinese Mainland, @emo64, @ptsa
- 🇳🇱 Dutch, @JSMPI
- 🇬🇧 English, @Clon1998
- 🇫🇷 French, @Jothoreptile, Arnaud Petetin, @dtourde
- 🇩🇪 German, @Clon1998
- 🇭🇺 Hungarian, @AntoszHUN
- 🇮🇹 Italian, @Livex97
- 🇧🇷 Portuguese Brasil, @opastorello
- 🇷🇴 Romanian, @vaxxi
- 🇷🇺 Russian, @teuchezh
- 🇹🇷 Turkish, @larinspub
- 🇺🇦 Ukrainian, @iZonex