-
Notifications
You must be signed in to change notification settings - Fork 0
Translation
Behaviour activation supports multiple languages and its easy to add additional languages. Adding a new language consists of two steps:
- Translations the actual app.
- Tell the application that the language exists.
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.
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.
- Open the index file located at
src/language/index.tsx. - Copy the the following line
import en from 'language/en';and replaceenwith your language code and place it below the otherimportlines. - 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';becomesexport type LanguageName = 'sv' | 'en;'. - At last add
'en': en,replaced with your language code just below the lineexport const languages: Languages = {. - 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.