For multi-language support the application uses:
- react-native-i18n for the integration of translations with user preferences
- YAML files in the directory
locales
- A YAML-to-typescript conversion script (
generate:locales
).
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.
es
for Spanish,de
for German, etc...). - Copy the content from the base language locales/en(
en
). - Proceed with the translation by editing the YAML and Markdown files.
- if is a YAML file (
*.yml
) translate only the text following the colon (e.g.today:
"today"
become in italiantoday:
"oggi"
). - if is a Mardown file (
*.md
) translate the text leaving the formatting as is.
- if is a YAML file (
- Check that the command:
npm run generate:locales
(oryarn generate:locales
) returns a success message. - 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:
-
Run the command:
npm run generate:locales
. -
Edit the file ts/i18n.ts by adding the new language in the variable
I18n.translations
.E.g. for German
I18n.translations = { en: locales.localeEN, it: locales.localeIT };
become
I18n.translations = { en: locales.localeEN, it: locales.localeIT de: locales.localeDE };