Localizations
note
This doc is for maintainers or for people who want to setup a similar translation process with a copy of the trustlines app.
The Trustlines App uses the localization framework FBT and the translation platform Crowdin for supporting different languages. The utility scripts in /translation/scripts
are used for enabling smooth integration of the mentioned tools. The scripts crowdinToFbt.js
, fbtToCrowdin.js
, and splitTranslation.js
are copied from the Origin Protocol mobile app repository and modified to our needs. The respective license can be found in /translation/LICENSE
#
PrerequisitesBefore being able to start the translation flow, make sure you did the following:
- Install Crowdin CLI tool.
- Create a
crowdin.yml
file by copying or renamingcrowdin.yml.dist
and set yourproject_id
andapi_token
there. The values can be found on the Crowdin platform.
#
Translation FlowRun yarn translate
to execute the whole translation flow. The command combines the following steps:
#
Collect Strings to be Translatedyarn fbt:manifest
: Generates FBT enum and source manifest files ->.enum_manifest.json
and.src_manifest.json
yarn fbt:collect
: Collects FTB translatable strings from source files ->.source_strings.json
yarn fbt:crowdin
: Runsnode translation/scripts/fbtToCrowdin.js
and converts.source_strings.json
into simple key-value json readable by Crowdin ->translation/crowdin/source/all-messages.json
#
Upload Collected Strings to Crowdinyarn crowdin:upload
: Runscrowdin upload sources
and uploads all source files undertranslation/crowdin/source
to Crowdin.
#
Import Translated Strings into Mobile Appyarn crowdin:download
: Runscrowdin download
and downloads all available translations files from Crowdin intotranslation/crowdin/translations
.yarn crowdin:fbt
: Runstranslation/scripts/crowdinToFbt.js
and converts respectivetranslation/crowdin/translations/all-messages_<language>.json
files to FBT-readable files intranslation/fbt/<language>.json
yarn fbt:translate
: Combines translations intranslation/fbt/<language>.json
to.translated_fbts.json
yarn fbt:split
: Runstranslation/scripts/splitTranslations.js
and splits.translated_fbts.json
into respective translation files insrc/shared/i18n/<language>.json
yarn crowdin:mdjson
: Runstranslation/scripts/mdToJson.js
and merges all markdown files intranslation/crowdin/translations/md
to a consumable JSON file insrc/shared/i18n/mdTranslations.js
#
Subset CommandsYou can also run steps 1 - 4 separately from steps 5 - 9.
yarn translate:upload
: Runs steps 1 - 4.yarn translate:download
: Runs steps 5 - 9.
#
Overriding .md FilesIf you want to override any of the .md files just create a copy of the file and change the .md extension to .override.md. Afterwards
run yarn crowdin:mdjson
this will read all .md files and will override the translation from the original file with the
content in the .override.md file.