October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

i18n in Expo and Next.js: One Shared Dictionary with a Fallback Language

A shared workspace package can hold locale IDs and dictionaries for Expo and Next.js, while each app selects its locale using platform-appropriate rules and applies explicit fallback behavior.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

You can keep translations in one shared workspace package and let Expo and Next.js handle locale selection in their own way. The shared package should define supported locale IDs, dictionaries, the default fallback locale, and—if both apps need it—a lookup helper that falls back when a key is missing. Expo can read device or app language settings; Next.js can use a locale in the URL or a request preference. Validate either choice against the same supported-locale list before loading strings.

How the shared-dictionary design works

Put framework-neutral translation data and locale definitions in a workspace package that both apps can import. Keep platform decisions in each app: Expo reads native language preferences, while Next.js resolves a web locale from routing or request preferences. This division shares the source of truth without forcing the two runtimes to share locale-detection behavior.

As an Amazon Associate I earn from qualifying purchases.

Expo documents workspace monorepos for sharing code, and Next.js provides transpilePackages to bundle local packages. The package structure itself is a project choice, not a framework requirement.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Suggested shared exports

  • A finite locales list and corresponding Locale type.
  • A single fallbackLocale constant, such as en if English is the product default.
  • Translation dictionaries, organized as locale modules or another shared data format.
  • A language-neutral lookup helper if both apps should use identical missing-key behavior.

Keep the shared package usable in both browser and native code: do not import server-only modules or framework-specific runtime APIs into it. For Next.js, dictionary loading can remain on the server when the page is a Server Component, avoiding sending the full dictionary to the client unnecessarily.

Define locale selection and fallback separately

There are two distinct cases: a requested locale may not be supported, or a supported locale may lack a particular translation key. Choose a supported fallback locale for the first case—or deliberately reject an unsupported route. For the second, check the active dictionary first and then the fallback dictionary. Do not assume a framework handles both cases automatically.

Normalize tags deliberately. For example, decide whether a request for en-US should map to the supported key en; a regional tag and a base-language key are not interchangeable unless your app explicitly makes them so.

Set up the shared package

  1. Choose the supported locale IDs. Define them once and reuse the same identifiers in Expo settings, Next.js routing, and dictionary keys.
  2. Choose the fallback locale. Make it explicit in the package rather than letting each app quietly invent a different default.
  3. Store or generate dictionaries from one source. Both apps should import the same translation data or build their dictionaries from a shared source, not maintain parallel copies.
  4. Confirm each app can resolve the workspace package. Expo’s monorepo guide covers workspace support; Next.js documents transpilePackages for local packages.
  5. Keep package code cross-platform. Put data and language-neutral functions there; put device APIs, request handling, and framework-specific loading in the consuming app.

Choose and apply a language in Expo

Expo’s localization guide demonstrates reading device preferences with expo-localization and using i18n-js to hold dictionaries. Its example selects a device language code and enables fallback when a key is missing. In a shared-package design, retain that platform-specific preference reading, but resolve the result against the shared locale list before selecting a dictionary.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Device preference need not be the only choice: an app can also provide a language selector where appropriate. Expo notes that iOS resets the app when the device language changes while it is running, whereas Android does not. An Android app may therefore need to refresh locale state when the app becomes active.

If users should be able to set the app language through system settings, declare supported native locales. Also check right-to-left layout behavior on the platforms you support; translating strings alone does not configure the entire interface.

Choose and apply a language in Next.js

For locale-specific URLs in the App Router, place route files under a dynamic segment such as app/[lang]. The Next.js internationalization guide describes subpath and domain routing, matching Accept-Language against supported locales, and using a default locale. The application remains responsible for validating the selected locale and loading its dictionary.

  1. Select a locale source. Use the route locale, a request preference, a cookie, or an explicit selector according to the product’s URL and persistence requirements.
  2. Validate before loading. Match the candidate against the shared locale list. For an unsupported route, decide whether to use the fallback or call notFound().
  3. Load the corresponding shared dictionary. Prefer server-side loading in a Server Component when client-side access is not needed.
  4. Enumerate static locale routes if useful. Next.js supports listing locale paths with generateStaticParams.
  5. Set the document language. Ensure the rendered HTML exposes the chosen locale through an appropriate lang attribute.

The Next.js guide demonstrates locale validation and dictionary loading, but does not prescribe per-key fallback. If the web app needs the same missing-key behavior as the native app, use an explicit shared lookup helper or implement that behavior in the web app.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Keep message lookup separate from localized formatting

A dictionary translates message text; it does not by itself format dates, numbers, currencies, units, lists, or plural forms. Once the locale is known, use standardized Intl APIs for locale-sensitive formatting. This keeps formatting behavior separate from choosing a message string and avoids hard-coding conventions into translations.

Decisions to make before shipping

  • Locale source: device or app settings in Expo; URL, request headers, cookies, or a selector on the web.
  • URL strategy: locale subpaths such as /fr/products or locale-specific domains, and whether the default locale has a prefix.
  • Fallback semantics: define separately what happens for an unsupported locale and for a missing key.
  • Dictionary loading: choose an eager shared object, per-locale modules, or lazy loading based on bundle needs.
  • Message features: decide whether keyed strings suffice or whether you need pluralization, extraction, translator context, or translation-management integration.
  • Platform coverage: check HTML language metadata, native locale declarations, right-to-left layout, and locale changes while the app runs.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.