For multi-language support the application uses:
- i18next for the integration of translations with user preferences
- JSON files in the directory
locales/{{lng}}wherelngis the language key code related to the source file in each directory
To add a new language you must:
- Clone the repository
- Create a new directory under locales using the language code as the name (e.g.
esfor Spanish,defor German, etc...). - Create a new file
index.jsonunder the new directory. - Copy the content from the base language locales/it.
- Replace Italian value strings with the translated one, but keep the key declaration (each JSON file MUST keep the same key structure).
- Remove all non-translated keys,
I18nextwill automatically proceed to use the base language value (itversion). - Create a PR using as title
Internationalization {New Language}(e.g.Internationalization Italiano)and apply the labelinternationalization.
If you want to see the result in the app you must edit the file ts/i18n.ts by adding the new language source file in the resource object.
E.g. for Spanish
```
import it from "../locales/it/index.json";
import en from "../locales/en/index.json";
import de from "../locales/de/index.json";
// ...other imports
const resources = {
it: {
index: it
},
en: {
index: en
},
de: {
index: de
}
};
```
become
```
import it from "../locales/it/index.json";
import en from "../locales/en/index.json";
import de from "../locales/de/index.json";
import es from "../locales/es/index.json";
// ...other imports
const resources = {
it: {
index: it
},
en: {
index: en
},
de: {
index: de
},
es: {
indes: es
}
};
```