# Localization

> Translate every grid string with the localeText catalog, format numbers, dates and money per locale, and pick the text direction from the locale.

Canonical: https://salmonui.dev/docs/data-grid/localization

## Text

Every visible and assistive string of the grid (pager, filter UI, menus,
column chooser, toolbar, empty and loading states, live announcements) comes
from one flat catalog. `DATA_GRID_DEFAULT_LOCALE_TEXT` is the built-in English
catalog; its keys are typed as `DataGridLocaleTextKey`. The `localeText`
prop merges overrides over English, so a partial catalog is fine:

```tsx
import { DataGrid, type DataGridLocaleText } from '@salmonui/data-grid';

const de: DataGridLocaleText = {
  noRows: 'Keine Datensätze vorhanden',
  pageOf: 'Seite {page} von {pageCount}',
  rowsSelected: { one: '1 Zeile ausgewählt', other: '{count} Zeilen ausgewählt' },
};

<DataGrid localeText={de} locale="de-DE" data={orders} columns={columns} />;
```

To localize every grid (and every other Salmon UI component) at once, put
them under a [`LocaleProvider`](https://salmonui.dev/docs/data-grid/locale-provider): its
catalog's `dataGrid` entry has the keys of this prop, the built-in
`@salmonui/core/locale/zh-TW` pack translates all of them, and a grid's own
`localeText` and `locale` still win over the provider's:

```tsx
import { LocaleProvider } from '@salmonui/core/locale';
import { zhTW } from '@salmonui/core/locale/zh-TW';

<LocaleProvider locale="zh-TW" localeText={zhTW}>
  <DataGrid data={orders} columns={columns} paging />
</LocaleProvider>;
```

A message is either a string with `{param}` placeholders or a set of plural
forms (`zero`, `one`, `two`, `few`, `many`, `other`) chosen with
`Intl.PluralRules` for the grid `locale`; `other` is required. Numeric
parameters are written with the locale's number format (`{count} items`
reads "22,095 items" in `en-US`, "22.095" in `de-DE`). The catalog
is plain JSON with no functions, so it can live in a JSON file or be loaded
in a server component and passed to a client `DataGrid`. Column headers are your
own `header` values, so translate them with the rest of your app.

## Formats

`locale` drives the `Intl` number, date and currency formatters of every
column `format` (`N2`, `C2`, `P1`, `yMMMd`, ...). `currency` sets
the currency of `C` formats, and `timeZone` the IANA time zone of
date formats; set `timeZone` for SSR so the server and the browser format
identically.

### Custom patterns

Besides the presets, `format` takes custom patterns that map onto `Intl`:

| Pattern | Meaning | `1234567.891` in `en-US` |
| --- | --- | --- |
| `#,##0.00` | Grouping, exactly two decimals | `1,234,567.89` |
| `0.0##` | One to three decimals, no grouping | `1234567.891` |
| `'USD' #,##0` | Quoted literal text, no decimals | `USD 1,234,568` |
| `$#,##0.00` | Unquoted `$`: the currency symbol of `currency` in the grid locale (`'$'` is a literal dollar sign) | `$1,234,567.89` (`€1,234,567.89` with `currency: 'EUR'`) |
| `0.0%` | Percent (the value is multiplied by 100) | `0.1234` → `12.3%` |
| `000` | Minimum integer digits | `7` → `007` |
| `#,##0.00;(#,##0.00)` | Negative section after `;` (no minus sign is added) | `-1234.5` → `(1,234.50)` |
| `0.0;-0.0;'nil'` | Third section for zero | `0` → `nil` |

Date patterns use the tokens `G` (era: `G` short such as `AD`, `GGGG` long,
`GGGGG` narrow), `y`, `M` / `L` (month: `MMM` / `MMMM` names in their in-date
form, `LLL` / `LLLL` the standalone form, which differ in e.g. `ru-RU`:
`d MMMM` → `11 ноября`, `LLLL` → `ноябрь`), `d`, `E`
(weekday), `c` (standalone weekday: `ccc` / `cccc` names, `c` the number of
the day in the locale's week), `h` / `H`, `m`, `s`, `f` (fraction of the
second, truncated to the token length: `f` tenths, `fff` milliseconds), `a` and
`z` (time zone name: `z` short such as `UTC` or `EST`, `zzzz` long), with
literal text in single quotes and `''` for a quote:
`yyyy-MM-dd HH:mm:ss.fff`, `EEE d MMM y 'at' h:mm a`, `h 'o''clock'`. A
format made only of the letters `G y M L d E h H m s` (such as `yMMMd`) is
read as a skeleton, not a pattern. Month and
weekday names, digits and separators still come from the grid `locale`. For
locale-ordered dates, pass an object with a CLDR skeleton instead of a
pattern: `format: { type: 'date', skeleton: 'yMMMEd' }` renders
`Thu, Mar 5, 2026` in `en-US` and `Do., 5. März 2026` in `de-DE`;
`{ type: 'date', skeleton: 'medium' }` stays date-only even on a `datetime`
column, and `{ type, format }` takes a pattern or skeleton in `format`
(`{ type: 'number', format: '#,##0.0' }`). The object
form also takes `currency`, `timeZone`, `minimumFractionDigits`,
`maximumFractionDigits` and `useGrouping`.

### Formatting in templates

`formatValue(value, format, { locale, currency, timeZone, type })` from
`@salmonui/data-grid/engine/locale` formats any value with the same vocabulary, for
cell templates, tooltips or text outside the grid. Formatters
are cached per locale, currency and time zone:

```tsx
import { formatValue } from '@salmonui/core/format';

const columns: DataGridColumn<Sale>[] = [
  {
    field: 'amount',
    renderCell: ({ value }) => formatValue(value, 'C0', { locale: 'de-DE', currency: 'EUR' }),
  },
];
```

Inside a template, `ctx.formattedValue` already holds the column's own
formatted text, and `ctx.column.formatValue(value, row)` formats another
value with the column's format.

### Live demo: Custom format patterns

Live demo: https://salmonui.dev/demos/data-grid/format-patterns

Number patterns (`#,##0.00`, `0.0##`, quoted literals, `%`, zero padding), date patterns with quoted text, a skeleton object, and `formatValue` in a cell template, switched between locales.

`Demo.tsx`:

```tsx
'use client';

import { useMemo, useState } from 'react';
import { formatValue } from '@salmonui/core/format';
import { DataGrid, type DataGridColumn } from '@salmonui/data-grid';
import { Select } from '@salmonui/dropdowns/select';

interface Sale {
  readonly id: number;
  readonly amount: number;
  readonly share: number;
  readonly units: number;
  readonly placed: Date;
}

const sales: Sale[] = [
  { id: 1, amount: 1234567.891, share: 0.1234, units: 7, placed: new Date(Date.UTC(2026, 2, 5, 14, 30)) },
  { id: 2, amount: 98.5, share: 0.5, units: 42, placed: new Date(Date.UTC(2026, 10, 21, 9, 5)) },
  { id: 3, amount: 0.25, share: 1, units: 315, placed: new Date(Date.UTC(2026, 0, 1, 0, 0)) },
];

const locales = ['en-US', 'de-DE', 'fr-FR'] as const;
const LOCALE_OPTIONS = locales.map((l) => ({ value: l, label: l }));

export default function FormatPatternsDemo() {
  const [locale, setLocale] = useState<(typeof locales)[number]>('en-US');
  // Only the template column reads `locale`; the memo keeps the definitions stable between renders.
  const columns = useMemo<DataGridColumn<Sale>[]>(() => [
    { field: 'id', header: '#', type: 'number', primaryKey: true, width: 60 },
    // Custom number patterns: grouping, fixed and optional decimals, a quoted literal, a percent.
    { id: 'grouped', field: 'amount', header: '#,##0.00', type: 'number', format: '#,##0.00', align: 'end', width: 150 },
    { id: 'optional', field: 'amount', header: '0.0##', type: 'number', format: '0.0##', align: 'end', width: 130 },
    { id: 'literal', field: 'amount', header: "'USD' #,##0", type: 'number', format: "'USD' #,##0", align: 'end', width: 150 },
    { field: 'share', header: '0.0%', type: 'number', format: '0.0%', align: 'end', width: 90 },
    { field: 'units', header: '000', type: 'number', format: '000', align: 'end', width: 80 },
    // Custom date patterns, a quoted literal, and a skeleton object.
    { id: 'iso', field: 'placed', header: 'yyyy-MM-dd HH:mm', type: 'datetime', format: 'yyyy-MM-dd HH:mm', width: 190 },
    { id: 'long', field: 'placed', header: "EEE d MMM y 'at' h:mm a", type: 'datetime', format: "EEE d MMM y 'at' h:mm a", width: 220 },
    { id: 'skeleton', field: 'placed', header: "{ skeleton: 'yMMMEd' }", type: 'datetime', format: { type: 'date', skeleton: 'yMMMEd' }, width: 170 },
    {
      id: 'template',
      field: 'amount',
      header: 'formatValue in a template',
      width: 220,
      // `formatValue` formats any value with the grid's format vocabulary, here in another currency.
      renderCell: ({ value }) => (
        <span>
          {formatValue(value, 'C0', { locale, currency: 'EUR' })} / {formatValue(value, 'C0', { locale, currency: 'JPY' })}
        </span>
      ),
    },
  ], [locale]);
  return (
    <>
      <div className="demo-toolbar">
        <label>
          Locale{' '}
          <Select aria-label="Locale" data={LOCALE_OPTIONS} value={locale} onValueChange={(value) => value != null && setLocale(value as (typeof locales)[number])} />
        </label>
      </div>
      <DataGrid<Sale>
        aria-label="Custom number and date format patterns"
        data={sales}
        columns={columns}
        height="auto"
        selection={false}
        locale={locale}
        currency="USD"
        timeZone="UTC"
      />
    </>
  );
}
```

## Accents and case

Search and filters compare text without case and with accents by default.
Two options, named the same everywhere, change that:

- `matchCase: true` makes the comparison case-sensitive
  (`filtering.matchCase`, `search.matchCase`, and per condition in
  `filtering.filters` or `api.filterColumn(field, operator, value, { matchCase })`).
- `ignoreAccents: true` folds diacritics before comparing, so `rene` finds
  `Renée` and `malaga` finds `Málaga` (`filtering.ignoreAccents`,
  `search.ignoreAccents`, per condition, and `columnChooser.ignoreAccents`).

Both options are reactive: changing them re-runs the active search and
filters.

### Live demo: Accent and case matching

Live demo: https://salmonui.dev/demos/data-grid/text-matching

Search and filter-row matching with `matchCase` and `ignoreAccents`, so "rene" finds "Renée" and "zoe" finds "ZOE" and "Zoë".

`Demo.tsx`:

```tsx
'use client';

import { useState } from 'react';
import { Checkbox } from '@salmonui/inputs/checkbox';
import { DataGrid, type DataGridColumn } from '@salmonui/data-grid';
import { TextField } from '@salmonui/inputs/text-field';

interface Person {
  readonly id: number;
  readonly name: string;
  readonly city: string;
}

const people: Person[] = [
  { id: 1, name: 'Renée Dubois', city: 'Besançon' },
  { id: 2, name: 'Rene Martin', city: 'Lyon' },
  { id: 3, name: 'José Álvarez', city: 'Málaga' },
  { id: 4, name: 'Jose Silva', city: 'Porto' },
  { id: 5, name: 'Zoë Müller', city: 'Zürich' },
  { id: 6, name: 'ZOE Novak', city: 'Brno' },
  { id: 7, name: 'Åsa Lindqvist', city: 'Göteborg' },
];

const columns: DataGridColumn<Person>[] = [
  { field: 'id', header: 'Id', type: 'number', primaryKey: true, width: 70 },
  { field: 'name', header: 'Name', width: 180 },
  { field: 'city', header: 'City', width: 150 },
];

export default function TextMatchingDemo() {
  const [text, setText] = useState('rene');
  const [matchCase, setMatchCase] = useState(false);
  const [ignoreAccents, setIgnoreAccents] = useState(true);
  return (
    <>
      <div className="demo-toolbar">
        <label>
          Search{' '}
          <TextField type="search" value={text} onValueChange={(value) => setText(value)} aria-label="Search text" />
        </label>
        <Checkbox checked={matchCase} onCheckedChange={(checked) => setMatchCase(checked)}>
          matchCase
        </Checkbox>
        <Checkbox checked={ignoreAccents} onCheckedChange={(checked) => setIgnoreAccents(checked)}>
          ignoreAccents
        </Checkbox>
      </div>
      {/* `search` and `filtering` are reactive: the options re-apply when they change. */}
      <DataGrid<Person>
        aria-label="People matched with accent and case options"
        data={people}
        columns={columns}
        height="auto"
        selection={false}
        locale="en-US"
        search={{ text, matchCase, ignoreAccents }}
        filtering={{ ui: 'row', matchCase, ignoreAccents }}
      />
    </>
  );
}
```

## Date editors and calendars

The `date` and `datetime` editors are a text input plus a calendar button. The
input shows the date in the numeric order of the grid `locale`
(`12/24/2026` in `en-US`, `24.12.2026` in `de-DE`, `2026/12/24` in `ja-JP`)
and also accepts ISO `2026-12-24`; `datetime` adds a 24-hour time
(`24.12.2026 14:30`, `am` / `pm` accepted). Text that does not parse keeps
the last valid value.

Alt+ArrowDown or the button opens a calendar dialog that follows the
WAI-ARIA date picker pattern: arrow keys move by day and week (mirrored
right to left), Home and End go to the start and end of the week, PageUp and
PageDown change the month (with Shift, the year), Enter or Space choose the
day, and Escape closes the calendar and returns focus to the input without
ending the edit. The `datetime` calendar also has a time input. See
[Accessibility](https://salmonui.dev/docs/data-grid/accessibility) for the full key map.

Weekday and month names come from `Intl.DateTimeFormat`, and the first day of
the week from `Intl.Locale` week info of the `locale` (Sunday in `en-US`,
Monday in `de-DE`, Saturday in `ar-EG`; browsers without week info use the
CLDR region table). Override it per column with
`editorProps.firstDayOfWeek` (`0` Sunday ... `6` Saturday):

```tsx
const columns: DataGridColumn<Booking>[] = [
  { field: 'arrival', type: 'date', editorProps: { firstDayOfWeek: 1 } },
  { field: 'checkIn', type: 'datetime', editorProps: { calendar: 'japanese' } },
];
```

The calendar grid is always laid out in Gregorian months, and stored values
are plain `Date`s. `editorProps.calendar` (default: the `locale`'s calendar,
so `-u-ca-` extensions such as `ja-JP-u-ca-japanese` work) relabels it where
the calendar shares the Gregorian months: `buddhist` (`th-TH`), `japanese`
and `roc` show their era years in the month heading. Calendars with other
months (`islamic-umalqura`, `hebrew`, `persian`, `chinese`, ...) keep the
Gregorian heading and give each day an accessible name and tooltip with the
date in that calendar; a month grid laid out in those calendars is not
offered.

### Live demo: Date picker and first day of week

Live demo: https://salmonui.dev/demos/data-grid/date-picker

The `date` and `datetime` editors open an accessible calendar whose weekday names, week start and month heading follow the grid `locale`, with a `firstDayOfWeek` override.

`Demo.tsx`:

```tsx
'use client';

import { useMemo, useState } from 'react';
import { DataGrid, type DataGridColumn } from '@salmonui/data-grid';
import { Select } from '@salmonui/dropdowns/select';
import { germanLocaleText } from '../../lib/locale-de';

interface Booking {
  readonly id: number;
  readonly guest: string;
  readonly arrival: Date;
  readonly checkIn: Date;
}

const bookings: Booking[] = [
  { id: 1, guest: 'Renée Dubois', arrival: new Date(Date.UTC(2026, 10, 2)), checkIn: new Date(Date.UTC(2026, 10, 2, 14, 30)) },
  { id: 2, guest: 'Kenji Sato', arrival: new Date(Date.UTC(2026, 10, 9)), checkIn: new Date(Date.UTC(2026, 10, 9, 16, 0)) },
  { id: 3, guest: 'Lena Fischer', arrival: new Date(Date.UTC(2026, 10, 18)), checkIn: new Date(Date.UTC(2026, 10, 18, 11, 15)) },
  { id: 4, guest: 'Somchai Wong', arrival: new Date(Date.UTC(2026, 11, 24)), checkIn: new Date(Date.UTC(2026, 11, 24, 20, 45)) },
];

const LOCALES = ['en-US', 'de-DE', 'en-GB', 'ar-EG', 'ja-JP-u-ca-japanese', 'th-TH'] as const;
const LOCALE_OPTIONS = LOCALES.map((l) => ({ value: l, label: l }));
const FIRST_DAY_OPTIONS = [
  { value: 'locale', label: 'From locale' },
  { value: '0', label: 'Sunday' },
  { value: '1', label: 'Monday' },
  { value: '6', label: 'Saturday' },
];

export default function DatePickerDemo() {
  const [locale, setLocale] = useState<string>('en-US');
  const [firstDay, setFirstDay] = useState<string>('locale');
  const columns = useMemo<DataGridColumn<Booking>[]>(() => {
    // `firstDayOfWeek` overrides the locale's week start (0 Sunday ... 6 Saturday).
    const editorProps = firstDay === 'locale' ? {} : { firstDayOfWeek: Number(firstDay) };
    return [
      { field: 'id', header: 'Id', type: 'number', primaryKey: true, width: 70 },
      { field: 'guest', header: 'Guest', width: 160 },
      { field: 'arrival', header: 'Arrival', type: 'date', format: 'yMMMd', width: 200, editorProps },
      { field: 'checkIn', header: 'Check-in', type: 'datetime', format: 'yMMMdHm', width: 240, editorProps },
    ];
  }, [firstDay]);
  return (
    <>
      <div className="demo-toolbar">
        <label>
          Locale{' '}
          <Select aria-label="Locale" data={LOCALE_OPTIONS} value={locale} onValueChange={(value) => value != null && setLocale(String(value))} />
        </label>
        <label>
          First day of week{' '}
          <Select aria-label="First day of week" data={FIRST_DAY_OPTIONS} value={firstDay} onValueChange={(value) => value != null && setFirstDay(String(value))} />
        </label>
      </div>
      {/* Double-click (or F2) a date cell, then Alt+ArrowDown or the calendar button opens the picker. */}
      <DataGrid<Booking>
        aria-label="Bookings with date and date-time editors"
        data={bookings}
        columns={columns}
        height="auto"
        locale={locale}
        timeZone="UTC"
        dir="auto"
        editing={{ mode: 'cell' }}
        {...(locale === 'de-DE' ? { localeText: germanLocaleText } : {})}
      />
    </>
  );
}
```

## Direction

`dir` sets the text direction: `'ltr'`, `'rtl'`, or `'auto'`, which follows
the script of `locale` (`ar`, `he`, `fa`, `ur`, ... render right to left).
Without `dir` the grid inherits the direction of its ancestors. A
right-to-left grid mirrors its layout and flips the arrow keys, including in
the pager. See [Right-to-left](https://salmonui.dev/docs/data-grid/rtl).

`localeText`, `locale`, `currency`, `timeZone` and `dir` are all reactive:
changing them re-renders labels and formatted cells in place, without
remounting the grid or losing its sort, filters, page or selection.

### Live demo: Localization

Live demo: https://salmonui.dev/demos/data-grid/localization

One grid switched at runtime between English, German (a complete localeText catalog, de-DE formats, EUR) and Arabic (ar-EG formats, EGP, dir auto turns it right to left) without remounting.

`Demo.tsx`:

```tsx
'use client';

import { useState } from 'react';
import { DataGrid, type DataGridColumn, type DataGridLocaleText, type DataGridSorting } from '@salmonui/data-grid';
import { Select } from '@salmonui/dropdowns/select';
import { createOrders, type Order } from '../../lib/fixtures';
import { germanLocaleText } from '../../lib/locale-de';

const orders = createOrders(500, 31);

const columns: DataGridColumn<Order>[] = [
  { field: 'id', header: 'Order', primaryKey: true, width: 130 },
  { field: 'customer', header: 'Customer', width: 150 },
  { field: 'country', header: 'Country', width: 140 },
  { field: 'quantity', header: 'Quantity', type: 'number', format: 'N0', align: 'end', width: 140 },
  { field: 'unitPrice', header: 'Unit price', type: 'number', format: 'N2', align: 'end', width: 145 },
  { field: 'amount', header: 'Amount', type: 'number', format: 'C2', align: 'end', width: 150 },
  { field: 'placed', header: 'Placed', type: 'datetime', format: 'yMMMd', width: 130 },
];

// A few Arabic overrides; every other string falls back to English.
const arabicLocaleText: DataGridLocaleText = {
  noRows: 'لا توجد سجلات',
  search: 'بحث',
  filter: 'تصفية',
  sortAscending: 'ترتيب تصاعدي',
  sortDescending: 'ترتيب تنازلي',
  clearSort: 'إزالة الترتيب',
  pageOf: 'الصفحة {page} من {pageCount}',
  pagerInfo: 'الصفحة {page} من {pageCount}',
  pagerItems: { one: '(سجل واحد)', other: '({count} سجل)' },
  pageSize: 'صفوف لكل صفحة',
  columnChooser: 'الأعمدة',
};

const LANGUAGES = {
  en: { label: 'English (en-US, USD)', locale: 'en-US', currency: 'USD', localeText: undefined },
  de: { label: 'Deutsch (de-DE, EUR)', locale: 'de-DE', currency: 'EUR', localeText: germanLocaleText },
  ar: { label: 'العربية (ar-EG, EGP, right-to-left)', locale: 'ar-EG', currency: 'EGP', localeText: arabicLocaleText },
} as const;
type Language = keyof typeof LANGUAGES;

const LANGUAGE_ITEMS = (Object.keys(LANGUAGES) as Language[]).map((key) => ({ value: key, label: LANGUAGES[key].label }));

// Constants: the option props are reactive, a new object each render would reset them.
const sorting: DataGridSorting = { sortBy: [{ field: 'amount', direction: 'desc' }] };
const filtering = { ui: 'menu' } as const;
const paging = { pageSize: 10, pageSizeOptions: [10, 25, 50] } as const;
const toolbar = ['search', 'columnChooser'] as const;

export default function LocalizationDemo() {
  const [language, setLanguage] = useState<Language>('en');
  const settings = LANGUAGES[language];
  return (
    <>
      <div className="demo-toolbar">
        <label>
          Language{' '}
          <Select aria-label="Language" data={LANGUAGE_ITEMS} value={language} onValueChange={(value) => value != null && setLanguage(value as Language)} />
        </label>
      </div>
      <DataGrid<Order>
        aria-label="Localized orders"
        data={orders}
        columns={columns}
        // All reactive: switching updates formats, labels and direction in place.
        locale={settings.locale}
        currency={settings.currency}
        timeZone="UTC"
        {...(settings.localeText ? { localeText: settings.localeText } : {})}
        // 'auto' follows the locale script: ar-EG renders right to left.
        dir="auto"
        sorting={sorting}
        filtering={filtering}
        paging={paging}
        search
        columnChooser
        columnMenu
        toolbar={toolbar}
        height={360}
      />
      <p className="demo-status">
        Sort, filter or change the page, then switch the language: the grid is not remounted, so it keeps its sort, filters and page while labels, number, currency and date formats and the direction change.
      </p>
    </>
  );
}
```

## API reference

See [`DataGridLocaleText`](https://salmonui.dev/docs/reference/data-grid/DataGridLocaleText),
[`DATA_GRID_DEFAULT_LOCALE_TEXT`](https://salmonui.dev/docs/reference/data-grid/DATA_GRID_DEFAULT_LOCALE_TEXT),
[`FormatOptions`](https://salmonui.dev/docs/reference/data-grid/engine/FormatOptions) and
[`formatValue`](https://salmonui.dev/docs/reference/data-grid/engine-locale/formatValue) in the API
reference.
