Skip to content

Scripts

Diego edited this page Dec 17, 2019 · 6 revisions

This section intends to explain all scripts in the folder /dev_scripts

translation

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)

Usage

Exporting strings for translation

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.

Importing strings

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.

Clone this wiki locally