-
Notifications
You must be signed in to change notification settings - Fork 27
Scripts
This section intends to explain all scripts in the folder /dev_scripts
The main intention of this script is to simplify the way that strings in localization files are manipulated by either translators or developers.
All localization files in the folder ./src/localization
like authStrings.json
, buttonStrings
, demoUserModalStrings
, etc. have a similar structure, represented by this example:
"gb": {
"logging_in": "Logging in...",
"login": "Login",
"password": "Password",
"repeat_password": "Please re-enter password",
},
"fr": {
"logging_in": "Connexion en cours",
"login": "Se connecter",
"password": "Mot de passe",
},
"gil": {
"logging_in": "Taninga bwa e na uki",
"login": "Kaukia",
"password": "Am ka-ukuki",
"user_name": "Aram ae kinaaki ikai"
},
"tl": {
"logging_in": "Rejistu hela...",
"login": "Rejistu",
"password": "Liafuan-pase",
"user_name": "Naran"
},
"la": {
"logging_in": "ກຳລັງເຂົ້າລະບົບ",
"login": "ເຂົ້າລະບົບ",
"password": "ລະຫັດຜ່ານ",
"user_name": "ຊື່ຜູ້ນຳໃຊ້"
}
}
In that case, authStrings.json
has different values related with its language. English is the default language for those cases in which a language does not have a translation.
In order to create a CSV file that Includes all the strings related with one selected language, French (fr) for example, this application is getting all the corresponding texts from the localization files and places them in a unique CSV file named, for this example, fr.csv
. As a general rule, [language].csv
Available languages to translate from English (at the moment), are:
- French (fr)
- Kiribati (gil)
- Tetum (tl)
- Lao (la)
yarn translation export [selectedLanguage]
# selectedLanguage can be any of this options: fr, gil, tl, la
After that, a file with extension .csv
will be added to ./src/localization/translations
. If the selectedLanguage is French, the new file will be fr.csv
.
That file can be edited using Google Sheets and when ready, save as .tsv
(tab separated values).
Important: Even if the file is not modified, once generated needs to be save as tsv
before being imported as json. (See complete example at the end)
The inverse process is importing the changes to its corresponding .json
file using the following command:
yarn translation import [selectedLanguage]
# selectedLanguage is the language to be imported: fr, gil, tl, la
# It should match with the language of the CSV file to be imported
After that, all localization files will be updated based on the changes that have been made in the CSV file.
In case a new language is added, the idea is to generate a file with, for example, French strings, and then remove the last column (the one that has the French words). The the process of exporting will be similar as any other existing language.
For example, for Portuguese the steps would be:
yarn translation export fr
- Remove the last column
- Add the Portuguese strings
yarn translation import pr
Then the process continues as any other language.
- Type:
yarn translation export fr
in the command line. A file named fr.csv should be generated insrc/localization/translations
- Open the generated CSV file in Google sheets
- Columns from left to right should show the corresponding files name, keys in English, values in English and values in selectedLanguage (in french for this example).
- Add a translation for a string that it doesn't has a value in French. Like in this example, add
THIS IS AN EXAMPLE
as a value forrepeat_password
in french.

- Download the file as
tsv
(tab separated values). That new file should be in your defaultDownloads
folder, and rename it asfr.tsv
(That's really important, otherwise it won't work) - Place
fr.tsv
insrc/localization/translations
- Check that the file looks like a TSV file:
Example:
- Then run:
yarn translation import fr
in the command line. - Find the successful message in the console.
- In
src/localization/authStrings.json
check that the added value must exist and it should be the same as the one previously created.
Example: