Skip to main content
Logo Appt Light

Localization on React Native

Assistive technologies, such as the screen reader, use the locale for the pronunciation of utterances. It is important to explictly set a locale for your app. An incorrect locale leads to unclear pronunciation. Also, setting a locale can help with displaying characters correctly.

In React Native, there is no standard for loading resources in your desired language. Various packages are available to help you achieve this. You can use expo-localization in combination with i18n-js to get the device locale and set translations for your app.

import * as Localization from 'expo-localization';
import i18n from 'i18n-js';

// Set the key-value pairs for the different languages you want to support.
i18n.translations = {
  en: { welcome: 'Appt accessibility' },
  nl: { welcome: 'Appt toegankelijkheid' },
};

// Set the locale once at the beginning of your app.
i18n.locale = Localization.locale;

Feedback?

Let us know!