Multi-language & currencies
Reach global customers with clean locale routing, localized currencies and dates, right-to-left layout support, and database schemas decoupled from display text.
Internationalization vs localization
Serving international visitors starts by separating two clean concerns. Internationalization (`i18n`) is the structural groundwork: storing neutral codes in your database, moving interface text into locale dictionaries, and formatting numbers and dates dynamically.
Localization (`l10n`) adapts that groundwork per market — translating UI copy into Spanish or Japanese, pricing plans in Euros or Yen, adapting date formats, and mirroring right-to-left layouts for Arabic or Hebrew.
Setting up clean i18n architecture early makes every additional market fast to launch instead of forcing fragile database and UI rewrites later.
Keeping database records language-independent
The fastest way to corrupt a multi-language app is storing translated display words in core columns. If an English checkout writes status = "Confirmed" while a Spanish checkout writes status = "Confirmado", admin filters and revenue reports break immediately.
Store canonical neutral values in Cloud and translate labels only when rendering screens or emails.
| Data type | Fragile localized storage | Clean language-independent storage |
|---|---|---|
| Status & roles | "Confirmado", "En attente" | Canonical lowercase codes: "confirmed", "pending", "canceled" |
| Prices & money | "$19.99" or float 19.99 | Integer minor units + ISO 4217 currency: amount_minor = 1999, currency = "USD" |
| Dates & bookings | "03/04/2026 2:00 PM" | UTC ISO-8601 timestamp (starts_at) plus IANA time zone ("Europe/Berlin") |
| Catalog copy | Multiplying title_en, title_es columns | Child product_translations table keyed by (product_id, locale) |
| User preference | Guessing solely from headers | BCP-47 locale tag ("en", "es", "ja", "ar") on users.preferred_locale |
{
"products": { "id": "prod_104", "sku": "MATCHA-100G", "status": "active" },
"product_translations": [
{ "product_id": "prod_104", "locale": "en", "title": "Ceremonial Matcha 100g" },
{ "product_id": "prod_104", "locale": "ja", "title": "宇治抹茶 100g" },
{ "product_id": "prod_104", "locale": "es", "title": "Matcha Ceremonial 100g" }
],
"product_prices": [
{ "product_id": "prod_104", "currency": "USD", "amount_minor": 3400, "stripe_price_id": "price_usd_..." },
{ "product_id": "prod_104", "currency": "EUR", "amount_minor": 3100, "stripe_price_id": "price_eur_..." }
]
}Always fall back cleanly to your default locale (en) when a newly added record lacks a secondary translation so visitors never see blank titles or raw dictionary keys.
Choosing clean locale routing and persistence
Pick a routing strategy matched to whether pages must rank in regional search results or sit behind user sign-in.
| Routing strategy | Example URL | Best suited for | SEO & UX trade-off |
|---|---|---|---|
| URL path prefixes | yourdomain.com/es/pricing, /ja/pricing | Public sites, stores, blogs, booking storefronts | Strongest SEO; pairs cleanly with hreflang and shareable links |
| Regional subdomains | es.yourdomain.com, jp.yourdomain.com | Distinct regional storefronts or legal entities | Requires extra DNS setup; see Subdomains & redirects |
| Profile + cookie | yourdomain.com/dashboard | Authenticated SaaS dashboards and private portals | Clean single URL; remembers each user's preference across devices |
Add reciprocal hreflang tags and canonical links on prefixed public routes so Google serves the right regional page. See Technical SEO & sitemaps.
Formatting currencies, dates, and Stripe Checkout
Never glue symbols manually ("$" + amount) or assume every currency divides by 100. Zero-decimal currencies such as Japanese Yen (JPY) and Korean Won (KRW) have no cents, and European locales swap commas and periods.
Standard `Intl` formatting
Use native Intl.NumberFormat and Intl.DateTimeFormat so decimal separators, symbol placement, and local date styles stay accurate with zero extra dependencies:
Formatting Examples (same underlying records)
- en-US + USD (4900 cents): $49.00
- de-DE + EUR (4500 cents): 45,00 €
- ja-JP + JPY (7200 yen): ¥7,200
- en-US date (UTC -> local): May 14, 2026, 2:30 PM
- fr-FR date (UTC -> local): 14 mai 2026 à 14:30Multi-currency Stripe payments
Never show an estimated frontend currency conversion while silently charging a different currency at checkout. Bind each supported currency to its own real Stripe Price ID in product_prices (ExaSpark always charges 0% platform fee on top of standard Stripe processing fees).
When a visitor picks EUR, launch Stripe Checkout with your EUR Price ID and persist the confirmed amount_minor and currency from the verified Stripe webhook. See Payments with Stripe.
Supporting right-to-left (RTL) layouts
Serving Arabic (ar), Hebrew (he), Persian (fa), or Urdu (ur) requires mirroring layout geometry alongside translated text:
- Toggle document direction dynamically. Set both
langanddir="rtl"(ordir="ltr") on the root<html>element whenever locale switches. - Use CSS logical properties. Write
margin-inline-start,padding-inline-end, andtext-align: startinstead of hardcodedleftandrightso sidebars and forms mirror automatically. - Mirror directional icons selectively. Flip back arrows and drawer chevrons in RTL while keeping brand logos, checkmarks, and numeric sequences unmirrored.
- Plan for European text expansion. German, French, and Spanish buttons often run
25%–35%wider than English. Check narrow frames in Browser Device Lab to prevent clipped labels.
Adding a new language step by step
Extract copy into typed locale dictionaries
Move nav labels, form placeholders, validation errors, and empty states into
locales/en.jsonand per-locale JSON files with automatic English fallback.Audit database codes and currency units
Confirm statuses use canonical enums, timestamps store UTC, and prices store integer minor units plus ISO currency codes.
Wire locale routing and switcher
Add URL prefixes for public pages, persist
preferred_localefor signed-in users, and add a clean header/footer language and currency switcher.Localize transactional emails
Pass each customer's
preferred_localeinto booking confirmation, receipt, and password templates so emails match the storefront.Verify layout expansion, RTL, and checkout in Preview
Inspect every locale across phone frames in Browser Device Lab and run one Stripe Test checkout per currency.
Add English (en), Spanish (es), and Japanese (ja) support. Move UI copy, validation errors, and email templates into typed JSON locale files with automatic fallback to English. Add /en, /es, and /ja URL prefixes with hreflang tags on public pages, save preferred_locale on users, add a header language and currency switcher (USD, EUR, JPY), format prices and dates via Intl (treating JPY as zero-decimal), and store canonical lowercase status enums in Cloud.
Add Arabic (ar) support with dynamic html dir="rtl" switching. Refactor hardcoded left/right spacing and alignments to CSS logical properties (margin-inline, padding-inline, text-align: start), mirror directional chevron icons in RTL, and confirm mobile drawers and forms have zero horizontal overflow.
Common mistakes and troubleshooting
| Symptom | Root cause | Exact fix |
|---|---|---|
| Buttons render raw keys like `nav.book` | Secondary locale lacks the key with no fallback helper | Return the default en translation whenever a key is missing |
| Japanese Yen displays `100x` off | Formatter divided JPY by 100 assuming two decimals | Track decimal precision per currency (0 for JPY/KRW, 2 for USD/EUR) |
| Admin filters miss non-English orders | Database stored translated status words | Store canonical enums (confirmed, pending) and map display labels only in UI |
| Spanish or German nav wraps or clips | Fixed button widths sized tightly around English | Use flexible padding, tighten verbose strings, and inspect narrow mobile frames |
| Receipt emails arrive in English | Checkout ignored buyer's active locale | Save locale on the order or user row and pass it into email templates |