Skip to main content

Mobile development · Intermediate · 32 min

Translate an Expo app with expo-localization and i18next

By Padding · Updated 18 Nov 2026
Expo SDK 58 · expo-localization 58.0 · i18next 27.2 · react-i18next 18.0 · Jest 30.5 · Node.js 26 (node:26 image)

You will have an Expo SDK 58 orders app in English, French, Swahili and Arabic that follows the phone's language, lets people pick another in settings, formats naira, shilling and CFA franc prices for their region, switches to right-to-left for Arabic and fails a check when a translation is missing.

On this page

An app that only speaks English shuts out people who would use it happily in French, Swahili or Arabic. Translating the words is the visible part. The rest is quieter: plural rules that differ by language (Arabic has six forms, French treats zero as singular), prices that keep their currency but change their look by region, dates in the reader's own time zone, and a whole layout that reads from the right in Arabic.

In this tutorial you build a small orders screen for a delivery app with customers in Lagos, Nairobi and Dakar. expo-localization tells the app which languages and region the phone is set to. i18next holds the translations and picks plural forms, and react-i18next re-renders screens when the language changes. Prices and dates use Intl, which is built into JavaScript; the Intl tutorial for the web covers that API in depth, so this one only uses what the app needs.

By the end the app follows the phone's language, offers its own language setting that is remembered, flips to right-to-left for Arabic, declares its languages so Android and iOS can offer a per-app language, and has Jest tests and a check script that catch a missing translation before your users do.

Step 1 · Create the project and install the libraries

Create an app from the SDK 58 default template. Naming the template version keeps later SDK releases from changing what you get:

Bash
cd ~
npx create-expo-app@5.0.0 i18n-demo --template default@sdk-58

On prepaid data, expect this command to download a few hundred megabytes: it fetches the template and installs every package an Expo app needs.

Install the libraries. npx expo install picks the versions that match SDK 58 for the two native modules: expo-localization reads the phone's settings, and AsyncStorage remembers the language a person picks. The three JavaScript libraries are pinned to exact versions with --save-exact. intl-pluralrules fills in Intl.PluralRules, which i18next needs for plurals and which the Hermes engine does not provide; the step on formatting explains why:

Bash
cd ~/i18n-demo
npx expo install expo-localization @react-native-async-storage/async-storage
npm install --save-exact i18next@27.2.9 react-i18next@18.0.3 intl-pluralrules@2.0.1

These installs are small by comparison, because they add a handful of packages to a project that already has its dependencies.

Check it worked

Bash
cd ~/i18n-demo
node -e "const d = require('./package.json').dependencies; for (const n of ['expo', 'expo-localization', '@react-native-async-storage/async-storage', 'i18next', 'react-i18next', 'intl-pluralrules']) console.log(n, d[n])"

You see expo ~58.1.0, expo-localization ~58.0.5, @react-native-async-storage/async-storage 2.2.0, i18next 27.2.9, react-i18next 18.0.3 and intl-pluralrules 2.0.1, or later patch versions of the first two.

Step 2 · Write the English strings and their translations

Remove the template's demo screens, components and theme so that only your files are routes. This deletes everything the template put under src, so copy anything you changed first:

Bash
cd ~/i18n-demo
rm -rf src/app src/components src/hooks src/constants src/global.css
mkdir -p src/app src/data src/i18n/locales src/__tests__

Each language gets one JSON file of strings, grouped by screen. English is the source: every other file has the same keys. Three conventions do most of the work:

  • {{name}} is a placeholder. The code passes the value, so the translator can move it wherever the sentence needs it.
  • A key with plural forms has one entry per form, with a suffix: items_one, items_other. The suffixes are the plural categories from the Unicode CLDR rules, and i18next picks one by calling Intl.PluralRules with the count you pass. The variable must be called count.
  • Keep whole sentences in one string. "You have" plus a number plus "orders" glued together in code cannot be translated into a language that puts the number last.
Bash
cd ~/i18n-demo
cat > src/i18n/locales/en.json <<'JSON'
{
  "home": {
    "title": "Orders",
    "greeting": "Hello, {{name}}",
    "summary_one": "You have {{count}} order on the way.",
    "summary_other": "You have {{count}} orders on the way.",
    "items_one": "{{count}} item",
    "items_other": "{{count}} items",
    "total": "Total: {{amount}}",
    "arrives": "Arrives {{date}}",
    "settingsLink": "Language settings"
  },
  "settings": {
    "title": "Language",
    "deviceLanguage": "Use the phone's language",
    "restartNeeded": "Close and reopen the app to switch the layout direction."
  }
}
JSON

French has three plural forms. one covers 0 and 1 ("0 article"), and many is for exact millions, where French writes "1 000 000 d'articles":

Bash
cat > src/i18n/locales/fr.json <<'JSON'
{
  "home": {
    "title": "Commandes",
    "greeting": "Bonjour, {{name}}",
    "summary_one": "Vous avez {{count}} commande en route.",
    "summary_many": "Vous avez {{count}} de commandes en route.",
    "summary_other": "Vous avez {{count}} commandes en route.",
    "items_one": "{{count}} article",
    "items_many": "{{count}} d’articles",
    "items_other": "{{count}} articles",
    "total": "Total : {{amount}}",
    "arrives": "Livraison le {{date}}",
    "settingsLink": "Réglages de langue"
  },
  "settings": {
    "title": "Langue",
    "deviceLanguage": "Utiliser la langue du téléphone",
    "restartNeeded": "Fermez puis rouvrez l’application pour changer le sens de l’affichage."
  }
}
JSON

Swahili has two forms, and the noun itself changes class: one item is kitu, several are vitu. The word oda is the same for one and many, but the file still has both keys, because a later edit may need them to differ. The last settings string is missing on purpose: translations often arrive in batches, and the next step catches the gap.

Bash
cat > src/i18n/locales/sw.json <<'JSON'
{
  "home": {
    "title": "Oda",
    "greeting": "Habari, {{name}}",
    "summary_one": "Una oda {{count}} njiani.",
    "summary_other": "Una oda {{count}} njiani.",
    "items_one": "Kitu {{count}}",
    "items_other": "Vitu {{count}}",
    "total": "Jumla: {{amount}}",
    "arrives": "Itafika {{date}}",
    "settingsLink": "Mipangilio ya lugha"
  },
  "settings": {
    "title": "Lugha",
    "deviceLanguage": "Tumia lugha ya simu"
  }
}
JSON

Arabic uses all six categories. The forms for zero, one and two have no number in them, because Arabic says "one product" and "two products" in words:

Bash
cat > src/i18n/locales/ar.json <<'JSON'
{
  "home": {
    "title": "الطلبات",
    "greeting": "مرحبًا، {{name}}",
    "summary_zero": "ليس لديك طلبات في الطريق.",
    "summary_one": "لديك طلب واحد في الطريق.",
    "summary_two": "لديك طلبان في الطريق.",
    "summary_few": "لديك {{count}} طلبات في الطريق.",
    "summary_many": "لديك {{count}} طلبًا في الطريق.",
    "summary_other": "لديك {{count}} طلب في الطريق.",
    "items_zero": "لا منتجات",
    "items_one": "منتج واحد",
    "items_two": "منتجان",
    "items_few": "{{count}} منتجات",
    "items_many": "{{count}} منتجًا",
    "items_other": "{{count}} منتج",
    "total": "المجموع: {{amount}}",
    "arrives": "يصل في {{date}}",
    "settingsLink": "إعدادات اللغة"
  },
  "settings": {
    "title": "اللغة",
    "deviceLanguage": "استخدم لغة الهاتف",
    "restartNeeded": "أغلق التطبيق وافتحه مرة أخرى لتغيير اتجاه العرض."
  }
}
JSON

Treat these translations as drafts. Before you ship, have a fluent speaker of each language read every string in the running app, whether a person or an AI tool wrote the first version. Context changes words: "Orders" as a screen title and "orders" in a sentence may need different forms.

Check it worked

Ask Intl which plural forms each language needs. Your files should have one entry per form for every plural key:

Bash
node -e "for (const l of ['en', 'fr', 'sw', 'ar']) console.log(l, new Intl.PluralRules(l).resolvedOptions().pluralCategories.join(' '))"

The output is en one other, fr one many other, sw one other and ar zero one two few many other. Compare it with the suffixes in each file.

Step 3 · Catch missing translations with a check script

i18next does not fail when a string is missing. With a fallback language set, it shows the English text instead, which is the right behaviour for users and the wrong one for you: nobody notices until a Swahili speaker sees English in the middle of the screen. A short script compares every file with English and exits with an error on any gap. It asks Intl.PluralRules for the forms each language needs, so it catches a missing Arabic _few without you listing Arabic's rules:

Bash
cd ~/i18n-demo
cat > scripts/check-translations.mjs <<'JS'
// Compares every language file with the English source: missing keys, missing plural
// forms, keys English no longer has, empty strings and {{placeholders}} that do not match.
import { readFileSync } from 'node:fs'

const source = 'en'
const languages = ['en', 'fr', 'sw', 'ar']
const pluralSuffix = /_(zero|one|two|few|many|other)$/

function flatten(object, prefix = '') {
  return Object.entries(object).flatMap(([key, value]) =>
    value !== null && typeof value === 'object'
      ? flatten(value, `${prefix}${key}.`)
      : [[`${prefix}${key}`, value]],
  )
}

function load(language) {
  const file = new URL(`../src/i18n/locales/${language}.json`, import.meta.url)
  return new Map(flatten(JSON.parse(readFileSync(file, 'utf8'))))
}

const placeholders = (text) => [...text.matchAll(/{{\s*([\w.]+)/g)].map((m) => m[1]).sort().join(',')

const english = load(source)
const plain = [...english.keys()].filter((key) => !pluralSuffix.test(key))
const plurals = [...new Set([...english.keys()].filter((key) => pluralSuffix.test(key)).map((key) => key.replace(pluralSuffix, '')))]

const problems = []
for (const language of languages) {
  const strings = load(language)
  // The plural forms this language needs, from the CLDR rules built into Intl.
  const forms = new Intl.PluralRules(language).resolvedOptions().pluralCategories
  for (const key of plain) {
    if (!strings.has(key)) problems.push(`${language}: missing ${key}`)
  }
  for (const base of plurals) {
    for (const form of forms) {
      if (!strings.has(`${base}_${form}`)) problems.push(`${language}: missing ${base}_${form}`)
    }
  }
  for (const [key, text] of strings) {
    const base = key.replace(pluralSuffix, '')
    const englishText = english.get(key) ?? english.get(`${base}_other`)
    if (englishText === undefined) {
      problems.push(`${language}: ${key} is not in ${source}.json`)
    } else if (typeof text !== 'string' || text.trim() === '') {
      problems.push(`${language}: ${key} is empty`)
    } else if (placeholders(text) !== placeholders(englishText) && !(pluralSuffix.test(key) && placeholders(text) === '')) {
      problems.push(`${language}: ${key} has {{${placeholders(text)}}}, ${source} has {{${placeholders(englishText)}}}`)
    }
  }
}

if (problems.length > 0) {
  console.error(problems.join('\n'))
  process.exitCode = 1
} else {
  console.log(`OK: ${languages.length} languages, ${english.size} English strings, no gaps`)
}
JS
npm pkg set scripts.i18n:check="node scripts/check-translations.mjs"

A plural form may leave out {{count}}, as the Arabic "one product" does, so the placeholder rule allows that one case. Everything else must use the same placeholders as English: a translator who types {{nom}} for {{name}} would otherwise ship a literal {{nom}}.

Run it:

Bash
npm run i18n:check

It prints sw: missing settings.restartNeeded and npm reports that the script failed. Add the Swahili string. Writing the file back through JSON.parse and JSON.stringify keeps it valid JSON:

Bash
cd ~/i18n-demo
node -e "
const fs = require('fs')
const file = 'src/i18n/locales/sw.json'
const strings = JSON.parse(fs.readFileSync(file, 'utf8'))
strings.settings.restartNeeded = 'Funga programu kisha uifungue tena ili kubadilisha mwelekeo wa maandishi.'
fs.writeFileSync(file, JSON.stringify(strings, null, 2) + '\n')
"

Check it worked

Bash
cd ~/i18n-demo
npm run i18n:check

The last line is OK: 4 languages, 12 English strings, no gaps. Run this script in your CI pipeline next to the tests, so a pull request that adds an English string without its translations fails there.

Step 4 · Set up i18next and pick the phone's language

getLocales() from expo-localization returns the phone's languages in the order the person set them, each with a languageCode such as fr and a regionCode such as SN. The list always has at least one entry. Many people in Nigeria, Kenya or Senegal have two or three languages in that list, often with one the app does not have first, such as Yoruba or Hausa. Pick the first language you have translations for rather than giving up after the first entry.

Keep this logic in a file with no imports, so Node.js and Jest can run it without the phone:

Bash
cd ~/i18n-demo
cat > src/i18n/languages.ts <<'TS'
// The languages the app ships translations for, and the name of each in its own language.
export const supportedLanguages = ['en', 'fr', 'sw', 'ar'] as const
export type Language = (typeof supportedLanguages)[number]

export const languageNames: Record<Language, string> = {
  en: 'English',
  fr: 'Français',
  sw: 'Kiswahili',
  ar: 'العربية',
}

// The two fields of expo-localization's Locale that this file reads.
type DeviceLocale = { languageCode: string | null; regionCode: string | null }

export function isSupported(code: string | null | undefined): code is Language {
  return supportedLanguages.some((language) => language === code)
}

// The first language in the phone's list that the app has translations for, else English.
export function pickLanguage(locales: readonly DeviceLocale[]): Language {
  for (const locale of locales) {
    if (isSupported(locale.languageCode)) return locale.languageCode
  }
  return 'en'
}

// Text follows the app language; numbers, dates and prices also follow the phone's region.
export function formattingLocale(language: Language, locales: readonly DeviceLocale[]): string {
  const region = locales[0]?.regionCode
  return region ? `${language}-${region}` : language
}
TS

The settings screen lists each language by its own name, "Kiswahili" rather than "Swahili", because a person looking for their language may not read the one the app is in.

Next, the i18next options. They live in their own file so the tests can build an instance from them without the phone-only parts:

Bash
cat > src/i18n/options.ts <<'TS'
import type { InitOptions } from 'i18next'

import ar from './locales/ar.json'
import en from './locales/en.json'
import fr from './locales/fr.json'
import sw from './locales/sw.json'
import { supportedLanguages } from './languages'

export const resources = {
  en: { translation: en },
  fr: { translation: fr },
  sw: { translation: sw },
  ar: { translation: ar },
}

export function i18nOptions(language: string): InitOptions {
  return {
    resources,
    lng: language,
    fallbackLng: 'en', // i18next 27 has no fallback language unless you set one
    supportedLngs: supportedLanguages,
    interpolation: { escapeValue: false }, // React Native's Text shows strings as text, never as HTML
    initAsync: false, // the strings are bundled, so i18next is ready before the first render
  }
}
TS

Bundling every language in the app means the strings work offline and cost no data after install. Four small files add a few kilobytes. With dozens of languages or long texts, load them on demand instead with an i18next backend.

Finally, the instance the app uses. The polyfill import comes first, so Intl.PluralRules exists before i18next looks for it:

Bash
cat > src/i18n/index.ts <<'TS'
// First: Hermes has no Intl.PluralRules, and i18next needs it to pick plural forms.
// The polyfill does nothing where the engine already has a complete one.
import 'intl-pluralrules'
import { getLocales } from 'expo-localization'
import i18n from 'i18next'
import { initReactI18next } from 'react-i18next'

import { pickLanguage } from './languages'
import { i18nOptions } from './options'

void i18n.use(initReactI18next).init(i18nOptions(pickLanguage(getLocales())))

export default i18n
TS

Check it worked

Node.js 26 runs TypeScript files directly when the types can be stripped out, so you can try languages.ts without a build. --no-warnings hides a note about the module type that does not matter here. Here a phone lists Yoruba first, then French, with the region set to Nigeria:

Bash
cd ~/i18n-demo
node --no-warnings --input-type=module -e "
import { pickLanguage, formattingLocale } from './src/i18n/languages.ts'
const phone = [{ languageCode: 'yo', regionCode: 'NG' }, { languageCode: 'fr', regionCode: 'NG' }]
const language = pickLanguage(phone)
console.log(language, formattingLocale(language, phone))
console.log(pickLanguage([{ languageCode: 'ha', regionCode: 'NG' }]))
"

It prints fr fr-NG, then en. The app skips Yoruba, which it has no strings for, and uses French; a phone with only Hausa gets English.

Step 5 · Format prices and dates with Intl

A price keeps the currency it was charged in. An order from Lagos costs naira whether the reader's phone is set to French or Swahili; what changes with the locale is how the amount looks: the symbol or code, where it goes, and which characters separate thousands and decimals. So the currency comes from your data, and the locale comes from the phone. expo-localization also has a currencyCode, but it is the currency of the phone's region, and on the web it is always null, so do not use it for prices.

Bash
cd ~/i18n-demo
cat > src/i18n/format.ts <<'TS'
// Prices keep the currency they were charged in; the locale only decides how they look.
export function formatMoney(amount: number, currency: string, locale: string): string {
  return new Intl.NumberFormat(locale, { style: 'currency', currency }).format(amount)
}

// A calendar day in the reader's time zone, written the way their locale writes dates.
export function formatDay(isoTime: string, locale: string, timeZone?: string): string {
  return new Intl.DateTimeFormat(locale, { dateStyle: 'long', timeZone }).format(new Date(isoTime))
}
TS

Three things to know about Intl in a React Native app:

  • Hermes, the JavaScript engine Expo apps run on, implements Intl.NumberFormat and Intl.DateTimeFormat by calling the phone's own formatters, as its Intl documentation explains. That keeps the app small, but output can differ a little between Android versions and iOS. A cheap Android phone on an older version may show CFA where a new one shows F CFA, so test on the oldest phone your users have.
  • Intl.PluralRules is not in Hermes's list, which is why index.ts loads the polyfill. Without it, i18next falls back to English-style _one and _other forms, and the Arabic and French plurals above would come out wrong.
  • Use the full locale with the region, such as en-NG, not only the language. en alone writes NGN 12,500.00, while en-NG writes ₦12,500.00.

Check it worked

Bash
cd ~/i18n-demo
node --no-warnings --input-type=module -e "
import { formatMoney, formatDay } from './src/i18n/format.ts'
console.log(formatMoney(12500, 'NGN', 'en-NG'))
console.log(formatMoney(12500, 'NGN', 'en'))
console.log(formatMoney(1250, 'KES', 'sw-KE'))
console.log(formatMoney(5000, 'XOF', 'fr-SN'))
console.log(formatDay('2026-12-05T22:30:00Z', 'sw-KE', 'Africa/Nairobi'))
console.log(formatDay('2026-12-05T22:30:00Z', 'fr-SN', 'Africa/Dakar'))
"

Node.js prints ₦12,500.00, NGN 12,500.00, Ksh 1,250.00, 5 000 F CFA, 6 Desemba 2026 and 5 décembre 2026. The CFA franc has no decimals, and French separates thousands with a narrow no-break space. The two dates are the same moment: 22:30 UTC on 5 December is already 6 December in Nairobi, three hours ahead, which is why formatDay takes the reader's time zone.

Step 6 · Build the orders screen

The screen shows three orders, each in the currency its city pays in. Put the data in its own file:

Bash
cd ~/i18n-demo
cat > src/data/orders.ts <<'TS'
export type Order = {
  id: string
  city: string
  items: number
  total: number // in the currency below: naira, shillings or CFA francs
  currency: 'NGN' | 'KES' | 'XOF'
  deliverOn: string // ISO 8601, in UTC
}

export const orders: Order[] = [
  { id: 'lagos', city: 'Lagos', items: 3, total: 12500, currency: 'NGN', deliverOn: '2026-12-05T09:00:00Z' },
  { id: 'nairobi', city: 'Nairobi', items: 1, total: 1250, currency: 'KES', deliverOn: '2026-12-08T07:30:00Z' },
  { id: 'dakar', city: 'Dakar', items: 12, total: 5000, currency: 'XOF', deliverOn: '2026-12-11T10:00:00Z' },
]
TS

A first root layout loads the i18n module before any screen renders. The next step replaces it with one that also remembers the person's choice:

Bash
cat > src/app/_layout.tsx <<'TSX'
import '../i18n'
import { Stack } from 'expo-router'

export default function RootLayout() {
  return <Stack />
}
TSX

The screen calls t from useTranslation, which re-renders the screen whenever the language changes. useLocales and useCalendars are the hook versions of getLocales and getCalendars: they re-render when the phone's settings change, which Android allows while the app is running.

Bash
cat > src/app/index.tsx <<'TSX'
import { useCalendars, useLocales } from 'expo-localization'
import { Link, Stack } from 'expo-router'
import { useTranslation } from 'react-i18next'
import { ScrollView, StyleSheet, Text, View } from 'react-native'

import { orders } from '../data/orders'
import { formatDay, formatMoney } from '../i18n/format'
import { formattingLocale, isSupported } from '../i18n/languages'

export default function OrdersScreen() {
  const { t, i18n } = useTranslation()
  const locales = useLocales()
  const timeZone = useCalendars()[0].timeZone ?? undefined
  const language = isSupported(i18n.language) ? i18n.language : 'en'
  const locale = formattingLocale(language, locales)

  return (
    <ScrollView contentContainerStyle={styles.container}>
      <Stack.Screen options={{ title: t('home.title') }} />
      <Text style={styles.heading}>{t('home.greeting', { name: 'Amina' })}</Text>
      <Text style={styles.text}>{t('home.summary', { count: orders.length })}</Text>
      {orders.map((order) => (
        <View key={order.id} style={styles.card}>
          <Text style={styles.city}>{order.city}</Text>
          <Text style={styles.text}>{t('home.items', { count: order.items })}</Text>
          <Text style={styles.text}>
            {t('home.total', { amount: formatMoney(order.total, order.currency, locale) })}
          </Text>
          <Text style={styles.text}>
            {t('home.arrives', { date: formatDay(order.deliverOn, locale, timeZone) })}
          </Text>
        </View>
      ))}
      <Link href="/settings" style={styles.link}>
        {t('home.settingsLink')}
      </Link>
    </ScrollView>
  )
}

// textAlign 'left' means "start": React Native moves it to the right in a right-to-left layout.
// Set it explicitly so text lines up with the start edge on both platforms.
const styles = StyleSheet.create({
  container: { padding: 24, gap: 16 },
  heading: { fontSize: 24, fontWeight: '700', textAlign: 'left' },
  text: { fontSize: 16, textAlign: 'left' },
  card: { padding: 16, gap: 4, borderRadius: 12, borderWidth: 1, borderColor: '#d9dce1' },
  city: { fontSize: 18, fontWeight: '600', textAlign: 'left' },
  link: { fontSize: 16, color: '#208AEF', paddingVertical: 8, textAlign: 'left' },
})
TSX

City names come from the data and stay as written. If your app needs them translated, store them translated in the data, not in the string files.

Give the cards room to grow. French and Swahili strings are often a third longer than English, so avoid fixed heights and widths on anything that holds text; design for translation and longer text goes into the layout side.

Check it worked

Build the web version, which bundles every screen and stops on a broken import:

Bash
cd ~/i18n-demo
npx expo export --platform web

The output lists the bundles and ends with Exported: dist. The link to /settings has no screen yet; the next step adds it.

Step 7 · Let people choose the language and handle right-to-left

The phone's language is a good default, but not everyone wants it. Someone may keep the phone in English and prefer to shop in Swahili. Save the choice with AsyncStorage and apply it at startup. When the choice changes the reading direction, Android and iOS need more than new strings: React Native's I18nManager sets the direction of the whole native layout, and it only takes effect after the app restarts.

Bash
cd ~/i18n-demo
cat > src/i18n/preferences.ts <<'TS'
import AsyncStorage from '@react-native-async-storage/async-storage'
import { getLocales, type Locale } from 'expo-localization'
import { I18nManager, Platform } from 'react-native'

import i18n from './index'
import { isSupported, pickLanguage, type Language } from './languages'

const KEY = 'app-language'

// At startup, and when the phone's languages change: the saved choice wins, else the phone's.
export async function syncLanguage(locales: readonly Locale[]): Promise<void> {
  const saved = await AsyncStorage.getItem(KEY)
  const language = isSupported(saved) ? saved : pickLanguage(locales)
  if (language !== i18n.language) await i18n.changeLanguage(language)
}

// Saves the choice and switches the text at once. Returns true when the layout direction
// also has to change, which on Android and iOS happens on the next start of the app.
export async function chooseLanguage(choice: Language | 'device'): Promise<boolean> {
  if (choice === 'device') await AsyncStorage.removeItem(KEY)
  else await AsyncStorage.setItem(KEY, choice)
  const language = choice === 'device' ? pickLanguage(getLocales()) : choice
  await i18n.changeLanguage(language)
  if (Platform.OS === 'web') return false // the root layout sets dir on the page instead
  const rtl = i18n.dir(language) === 'rtl'
  I18nManager.allowRTL(rtl)
  I18nManager.forceRTL(rtl)
  return rtl !== I18nManager.isRTL
}
TS

i18n.dir() returns rtl for Arabic, Hebrew, Persian, Urdu and other right-to-left languages. The function always calls forceRTL with the direction of the new choice, so a person who picks Arabic and then English before restarting does not end up with an English app laid out from the right. forceRTL is remembered by the phone between starts.

Replace the root layout. It waits for the saved language before showing anything, so the first screen never appears in the wrong language for a moment. On the web there is no I18nManager, so it sets the page's lang and dir attributes, which the browser uses for direction and for picking fonts and hyphenation:

Bash
cat > src/app/_layout.tsx <<'TSX'
import '../i18n'
import { useLocales } from 'expo-localization'
import { Stack } from 'expo-router'
import { useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { Platform } from 'react-native'

import { syncLanguage } from '../i18n/preferences'

export default function RootLayout() {
  const { i18n } = useTranslation()
  const locales = useLocales()
  const [ready, setReady] = useState(false)

  useEffect(() => {
    syncLanguage(locales).finally(() => setReady(true))
  }, [locales])

  useEffect(() => {
    if (Platform.OS === 'web') {
      document.documentElement.lang = i18n.language
      document.documentElement.dir = i18n.dir()
    }
  }, [i18n, i18n.language])

  if (!ready) return null
  return <Stack />
}
TSX

The settings screen lists the four languages as radio buttons, plus a way back to the phone's language:

Bash
cat > src/app/settings.tsx <<'TSX'
import { Stack } from 'expo-router'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
import { Pressable, StyleSheet, Text, View } from 'react-native'

import { languageNames, supportedLanguages, type Language } from '../i18n/languages'
import { chooseLanguage } from '../i18n/preferences'

export default function LanguageSettings() {
  const { t, i18n } = useTranslation()
  const [restartNeeded, setRestartNeeded] = useState(false)

  async function choose(choice: Language | 'device') {
    setRestartNeeded(await chooseLanguage(choice))
  }

  return (
    <View style={styles.container}>
      <Stack.Screen options={{ title: t('settings.title') }} />
      <View role="radiogroup" style={styles.group}>
        {supportedLanguages.map((code) => {
          const selected = i18n.language === code
          return (
            <Pressable
              key={code}
              role="radio"
              aria-checked={selected}
              onPress={() => choose(code)}
              style={[styles.option, selected && styles.selected]}
            >
              <Text style={styles.label}>{languageNames[code]}</Text>
            </Pressable>
          )
        })}
      </View>
      <Pressable role="button" onPress={() => choose('device')} style={styles.option}>
        <Text style={styles.label}>{t('settings.deviceLanguage')}</Text>
      </Pressable>
      {restartNeeded && <Text style={styles.note}>{t('settings.restartNeeded')}</Text>}
    </View>
  )
}

const styles = StyleSheet.create({
  container: { flex: 1, padding: 24, gap: 16 },
  group: { gap: 8 },
  option: { minHeight: 48, justifyContent: 'center', paddingHorizontal: 16, borderRadius: 12, borderWidth: 1, borderColor: '#d9dce1' },
  selected: { borderColor: '#0b0c0e', borderWidth: 2 },
  label: { fontSize: 16, textAlign: 'left' },
  note: { fontSize: 16, textAlign: 'left' },
})
TSX

A few rules keep a right-to-left layout correct without extra code:

  • Use start and end rather than left and right for margins, padding and positions (marginStart, paddingEnd, start: 0). React Native swaps them in a right-to-left layout. Rows (flexDirection: 'row') already run from the right.
  • Set textAlign: 'left' on text, as above, and React Native treats it as "start".
  • Mirror icons that point somewhere, such as back and forward arrows, by checking I18nManager.isRTL. Leave icons that do not point, such as a search glass or a play symbol, as they are.

Asking people to restart is the simplest correct approach. If you want the switch to happen at once, Expo's localisation guide reloads the app with Updates.reloadAsync() from expo-updates, and Expo Router's LocaleProvider updates the direction of headers and swipe gestures without a reload.

Check it worked

Export the app again and serve the export:

Bash
cd ~/i18n-demo
npx expo export --platform web
Bash
npx expo serve

Open http://localhost:8081 in your browser. The orders screen appears in your browser's language if it is one of the four, else in English. Tap the language settings link and choose Kiswahili: the screen title becomes "Lugha", and after you go back the orders read "Vitu 3", "Kitu 1" and "Vitu 12". Reload the page and Swahili stays. Choose العربية and the page reads from the right, with the city names and text aligned to the right edge. Choose the last option to return to the browser's language. Stop the server with Ctrl+C.

Step 8 · Declare the app's languages to Android and iOS

Android 13 and later and recent iOS versions let people set a language for one app in the system settings, separate from the phone's language. The system only offers this for apps that declare their languages. The expo-localization config plugin does it from app.json. Replace any expo-localization entry in the plugin list with one that names the four languages:

Bash
cd ~/i18n-demo
node -e "
const fs = require('fs')
const app = JSON.parse(fs.readFileSync('app.json', 'utf8'))
const others = (app.expo.plugins ?? []).filter((p) => (Array.isArray(p) ? p[0] : p) !== 'expo-localization')
app.expo.plugins = [...others, ['expo-localization', { supportedLocales: ['en', 'fr', 'sw', 'ar'] }]]
fs.writeFileSync('app.json', JSON.stringify(app, null, 2) + '\n')
"

The plugin's supportsRTL option is true by default in SDK 58, so a phone set to Arabic gets a right-to-left layout without the settings screen. On iOS that only happens when Arabic is in supportedLocales, which is one more reason to keep the list complete.

On Android the plugin writes a locales_config.xml file, points the manifest at it, and adds resourceConfigurations to app/build.gradle. That last line also strips other languages from the libraries in your app, which makes the download smaller but means a system dialog from a library shows in English for a language you did not list. Add a language to this list at the same time as you add its JSON file.

Check it worked

Preview the iOS settings without generating the ios folder:

Bash
cd ~/i18n-demo
npx expo config --type introspect --json > introspect.json
node -e "console.log(require('./introspect.json').ios.infoPlist.CFBundleLocalizations.join(' '))"
rm introspect.json

It prints en fr sw ar, the value of CFBundleLocalizations in the app's Info.plist. Then generate the Android project and look at what the plugin wrote:

Bash
cd ~/i18n-demo
npx expo prebuild --no-install --platform android
cat android/app/src/main/res/xml/locales_config.xml
grep -o 'android:localeConfig="[^"]*"' android/app/src/main/AndroidManifest.xml
grep 'resourceConfigurations' android/app/build.gradle

The XML file lists <locale android:name="en"/> and the same for fr, sw and ar. The manifest line is android:localeConfig="@xml/locales_config", and build.gradle has resourceConfigurations += ["b+en", "b+fr", "b+sw", "b+ar"]. The android folder is generated output and the template's .gitignore already excludes it. The next command deletes it; npx expo prebuild or npx expo run:android writes it again when you need it:

Bash
cd ~/i18n-demo
rm -rf android

Try it on a phone

Start the development server and open the app in Expo Go, as in the first Expo tutorial:

Bash
cd ~/i18n-demo
npx expo start

In Expo Go, change the whole phone's language to French or Swahili and reopen the app. Choosing Arabic in the app's settings shows the restart message, but Expo Go resets the forced direction, so the right-to-left switch from the settings screen only works in a development build or a release build. A phone set to Arabic still shows the right-to-left layout in Expo Go. The per-app language setting in Android and iOS system settings also needs a build of your own app, because the supportedLocales you declared are written into your app's native project, which Expo Go does not use.

Step 9 · Test plurals and prices with Jest

Set up Jest with Expo's preset, as in the Larkfield testing tutorial:

Bash
cd ~/i18n-demo
npx expo install jest-expo jest @types/jest -- --save-dev
npm pkg set jest.preset=jest-expo scripts.test=jest

The tests build a fresh i18next instance per language from the same options the app uses, so they check your real JSON files. Intl puts no-break spaces inside some formatted numbers, so the price tests compare with plain spaces:

Bash
cat > src/__tests__/i18n.test.ts <<'TS'
import { createInstance } from 'i18next'

import { formatDay, formatMoney } from '../i18n/format'
import { formattingLocale, pickLanguage } from '../i18n/languages'
import { i18nOptions } from '../i18n/options'

// Some locales put no-break spaces in numbers. Compare them as ordinary spaces.
const plain = (text: string) => text.replace(/[  ]/g, ' ')

function translatorFor(language: string) {
  const i18n = createInstance()
  void i18n.init(i18nOptions(language))
  return i18n.getFixedT(language)
}

describe('plural forms', () => {
  test('English has one and other', () => {
    const t = translatorFor('en')
    expect([1, 3].map((count) => t('home.items', { count }))).toEqual(['1 item', '3 items'])
  })

  test('French uses the singular for 0 and its own form for millions', () => {
    const t = translatorFor('fr')
    expect([0, 1, 2, 1000000].map((count) => t('home.items', { count }))).toEqual([
      '0 article',
      '1 article',
      '2 articles',
      '1000000 d’articles',
    ])
  })

  test('Swahili changes the noun from kitu to vitu', () => {
    const t = translatorFor('sw')
    expect([1, 12].map((count) => t('home.items', { count }))).toEqual(['Kitu 1', 'Vitu 12'])
  })

  test('Arabic uses all six forms', () => {
    const t = translatorFor('ar')
    expect([0, 1, 2, 3, 11, 100].map((count) => t('home.items', { count }))).toEqual([
      'لا منتجات',
      'منتج واحد',
      'منتجان',
      '3 منتجات',
      '11 منتجًا',
      '100 منتج',
    ])
  })
})

test('the name goes where each language puts it', () => {
  expect(translatorFor('fr')('home.greeting', { name: 'Amina' })).toBe('Bonjour, Amina')
  expect(translatorFor('ar')('home.greeting', { name: 'Amina' })).toBe('مرحبًا، Amina')
})

test('Arabic is right to left and Swahili is not', () => {
  const i18n = createInstance()
  void i18n.init(i18nOptions('ar'))
  expect(i18n.dir()).toBe('rtl')
  expect(i18n.dir('sw')).toBe('ltr')
})

describe('prices keep their currency and follow the locale', () => {
  test.each([
    { amount: 12500, currency: 'NGN', locale: 'en-NG', expected: '₦12,500.00' },
    { amount: 12500, currency: 'NGN', locale: 'en', expected: 'NGN 12,500.00' },
    { amount: 1250, currency: 'KES', locale: 'sw-KE', expected: 'Ksh 1,250.00' },
    { amount: 5000, currency: 'XOF', locale: 'fr-SN', expected: '5 000 F CFA' },
  ])('$amount $currency in $locale', ({ amount, currency, locale, expected }) => {
    expect(plain(formatMoney(amount, currency, locale))).toBe(expected)
  })
})

test('dates use the reader’s time zone', () => {
  // 22:30 UTC on 5 December is already 6 December in Nairobi (UTC+3).
  expect(formatDay('2026-12-05T22:30:00Z', 'sw-KE', 'Africa/Nairobi')).toBe('6 Desemba 2026')
  expect(formatDay('2026-12-05T22:30:00Z', 'fr-SN', 'Africa/Dakar')).toBe('5 décembre 2026')
})

describe('choosing a language', () => {
  test('skips phone languages the app has no strings for', () => {
    const phone = [
      { languageCode: 'yo', regionCode: 'NG' },
      { languageCode: 'fr', regionCode: 'NG' },
    ]
    expect(pickLanguage(phone)).toBe('fr')
    expect(formattingLocale('fr', phone)).toBe('fr-NG')
  })

  test('falls back to English', () => {
    expect(pickLanguage([{ languageCode: 'ha', regionCode: 'NG' }])).toBe('en')
  })
})
TS

These tests run on Node.js and its ICU locale data, not on Hermes and the phone's formatters, so they prove your strings and your logic, not the exact characters every phone draws. Keep a manual check on an old Android phone in your release routine.

Check it worked

Bash
cd ~/i18n-demo
npm test
npm run i18n:check

Jest reports Tests: 13 passed, 13 total, and the check prints its OK line. To see a test catch a real mistake, rename items_few in ar.json to items_fwe: the Arabic test fails because 3 now comes out as 3 منتج from the _other form, and the check script reports both ar: missing home.items_few and ar: home.items_fwe is not in en.json. Change it back afterwards.

Clean up

When you have finished with the project, delete it. This removes the whole folder, including any changes you made:

Bash
cd ~
rm -rf ~/i18n-demo

Next steps

Need this done for you?

Padding does this work for growing companies, from the first diagnosis to a system that keeps working.

Platform Engineering

Get new tutorials

New tutorials, about twice a month.