Skip to content

Translation

Robert Johansson edited this page May 25, 2021 · 1 revision

Translation

Behaviour activation supports multiple languages and its easy to add additional languages. Adding a new language consists of two steps:

  1. Translations the actual app.
  2. Tell the application that the language exists.

Translating the application

The first step in order to translate the application is to make a copy of the English translation located at src/language/en.tsx and name it in accordance to the ISO 639-1 standard (if you're unsure what language code to use you can find a list of them all over here). You can now open the file and change the occurrences of en at the start and end of the file to your language code. You're now ready to start translating!

Each line contains a so called key-value pair. The 'key' (left) represent where in the application the text is located and the 'value' (right) represents the text that is displayed. Note: The 'keys' should always be the same and should not be changed. To translate the application simply change the 'value' within the two ' (quotation marks) to the translated word/sentence. If you're unsure how to translate a specific sentence check out the 'key' for a clue of the context. It's also recommended to use the application itself to see where values are located.

Adding a new language to the application

To add a new language to the application we have to modify some of the code located in the src/language/index.tsx. If you're not a coder don't be alarmed! We will go through everything you need change step by step.

  1. Open the index file located at src/language/index.tsx.
  2. Copy the the following line import en from 'language/en'; and replace en with your language code and place it below the other import lines.
  3. Add your language code to the line starting with export type LanguageName = 'sv' by adding | 'en' replaced with your language code at the end of the line just before the ; character. Example: export type LanguageName = 'sv'; becomes export type LanguageName = 'sv' | 'en;'.
  4. At last add 'en': en, replaced with your language code just below the line export const languages: Languages = {.
  5. You're done!

The language should now be available to the application. If you want to try it out yourself check out the Building section above on how to build a Development build.

To include the translation with the published version of the application push your changes to its own branch and create a pull request for others to review. When the pull request has been approved a developer will merge your changes into the main branch and the translation will be included with the next publishing build of the application.

Clone this wiki locally