Skip to content

Set Up Internationalization

Introduction

RN Launchpad ❤️ Lingui. Lingui uses po files that are widely used by professional translators. Lingui makes using them seamless.

Setting Up the Languages

  1. In /lib/constants.ts, add or remove languages from SUPPORTED_LANGUAGES.
  2. If you want to have a default language other than English, you can adjust sourceLocale in /lingui.config.js
  3. Adding new strings to translate is easy, the basic form is just <Text>{tA new phrase to translate.}</Text>.
  4. If you have added a new language or a new phrase, run npm run extract from the root directory of your project in your terminal. Lingui will automatically create a .po file for all your languages with all the strings of your project. Above each string you will see the place where it is used.
  5. Once you have translated everything, run npm run compile, again from the root directory of your project in your terminal. Lingui will compile the .po files into .json files that will be used to display the translations.
  6. If you save .tsx files anywhere other than /app or /components, you will need to add the folder in lingui.config.js.

What If You Don’t Need Internationalization?

If internationalization is not neededd, you have two options:

  • Simply ignore it and do not display the language switcher component. The default language (English, unless specified otherwise) will be used.
  • If you are certain you will never need translations, consider uninstalling Lingui and @formatjs tools from the project and replace all {t`some string`} with some string.

More Info

This only scratches the surface of what Lingui can do (pluralization, interpolation, formatting dates and numbers), of course. For more information, please check out the Lingui documentation.