To add a new language translation to Maputnik, follow these three steps:
1. Edit configuration
Add the new language's ISO Code to the configuration files in alphabetical order:
- Add the ISO Code to the
locales array in /i18next-parser.config.ts. - Add the ISO Code and its localized name to the supported languages list in
/src/i18n.ts.
2. Generate and populate translation strings
Run the i18n refresh command to generate a new directory under /src/locales/ for your language:
npm install
npm run i18n:refresh
Locate the newly generated translation.json file and replace every instance of the placeholder __STRING_NOT_TRANSLATED__ with the actual translation. Ensure all keys are translated.
3. Test the locale
Start a local instance of Maputnik to verify the implementation:
npm run start
npm install
npm run i18n:refresh
npm run start