# 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.

- Canonical: https://exaspark.ai/docs/internationalization-l10n/

## 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` |

```json
{
  "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](https://exaspark.ai/docs/subdomains-and-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](https://exaspark.ai/docs/technical-seo-and-sitemaps/).

> **Note:** Avoid irreversible IP-based redirects without a visible language switcher. Travelers and expats frequently want English while visiting Tokyo or Spanish while browsing from New York.

## 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:

```text
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:30
```

### Multi-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](https://exaspark.ai/docs/payments/).

## 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 `lang` and `dir="rtl"` (or `dir="ltr"`) on the root `<html>` element whenever locale switches.
- **Use CSS logical properties.** Write `margin-inline-start`, `padding-inline-end`, and `text-align: start` instead of hardcoded `left` and `right` so 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](https://exaspark.ai/docs/device-lab/) to prevent clipped labels.

## Adding a new language step by step

1. **Extract copy into typed locale dictionaries** — Move nav labels, form placeholders, validation errors, and empty states into `locales/en.json` and per-locale JSON files with automatic English fallback.
2. **Audit database codes and currency units** — Confirm statuses use canonical enums, timestamps store UTC, and prices store integer minor units plus ISO currency codes.
3. **Wire locale routing and switcher** — Add URL prefixes for public pages, persist `preferred_locale` for signed-in users, and add a clean header/footer language and currency switcher.
4. **Localize transactional emails** — Pass each customer's `preferred_locale` into booking confirmation, receipt, and password templates so emails match the storefront.
5. **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.

> **Example prompt (App):** 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.

> **Example prompt (App):** 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 |

## Next steps

- [Technical SEO & sitemaps](https://exaspark.ai/docs/technical-seo-and-sitemaps/) — Configure canonical URLs, sitemaps, and multilingual search signals cleanly.
- [Browser Device Lab](https://exaspark.ai/docs/device-lab/) — Test long translated labels and RTL mobile layouts across phone sizes.
- [Payments with Stripe](https://exaspark.ai/docs/payments/) — Configure multi-currency Stripe prices with 0% ExaSpark platform fee.

## From the blog

- [What is responsive design?](https://exaspark.ai/blog/what-is-responsive-design/) — Keep translated buttons, menus, and forms clean on every screen size.
- [SEO and GEO for a new website](https://exaspark.ai/blog/seo-and-geo-for-a-new-website/) — Structure regional pages for Google Search and AI discovery.
- [Website accessibility basics](https://exaspark.ai/blog/website-accessibility-basics/) — Pair proper `lang` and `dir` attributes with screen-reader clarity.
