Define new language: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
[[Category:ARIS:Define new language]] | [[Category:ARIS:Define new language]] | ||
In this section you will find the information about the multilanguage system, this will help you to add new languages to the ARIS application. | In this section you will find the information about the multilanguage system, this will help you to add new languages to the ARIS application. | ||
Revision as of 14:12, 22 February 2023
In this section you will find the information about the multilanguage system, this will help you to add new languages to the ARIS application.
Introducction[edit]
The multilanguage system is composed by five main files: langContext.js, index.js, NavBar.js, languageList.json, language json files. You will find these files in the FrontEnd folder in ARIS system files.
langConext.js[edit]
In this file you will find a provider component LangProvider that will wraps the app's main component tree, providing language switching functionality using react-intl. This component sets up two pieces of state using useState:
· messages: a state variable that holds the current language messages. This is initially set to the default language messages.
· locale: a state variable that holds the current locale code. This is initially set to the default locale code for English language (en-GB).
Also this file contains a function called establishLanguage, which takes in a language label as a parameter. This function is responsible for loading the corresponding language messages based on the selected language label.
index.js[edit]
Within this file the LangProvide defined in the langContext.js file, wraps the application to allow the language switching functionality to work on the system.
[edit]
In this file you will find the dropdown menu where you can visually select the different languages. The menu takes all the languages that the languageList.json file contains.
languageList.json[edit]
This file contains all the languages that the multilanguage system of the ARIS application can handle. All the languages it contains will appear in the dropdown menu on the app's navigation bar.
Language json files[edit]
By default, the ARIS system contains language json files that correspond to the Spanish and English languages. These files contain all the translations of the ARIS application, they follow a json structure where the key has to be the same in all the language files, you can see the example in the images below.


How to add a new language?[edit]
Now that we briefly know how the multilanguage system works, it is time to know how to add a new language. Thanks to this system you only have to follow two simple steps that we explain below.
· Step 1: Add a new language json file. Remember that it must follow the same structure as the files for other languages, so they must all contain the same keys. We recommend naming the new files as the ISO 639-1 code of the new language.
· Step 2: Add the new language to the languageList.json file just as the other languages are added.
You don't have to worry about modifying other files, if you have followed the above two steps you have successfully added a new language to the ARIS system.