---
url: https://akinozgen.github.io/datagrids/guide/i18n.md
description: >-
  Message packs (en, tr), locale resolution, overriding strings, locale-aware
  search and sorting, number and date formats, and right-to-left layouts.
---

# Localization & RTL

## Messages

The library ships two complete message packs, `en` and `tr`. Every user-visible string — the search
placeholder, pager labels, state texts, error messages, screen-reader announcements — comes from
the pack; modules (column menu, selection, export, row actions…) carry their own small packs in the
same two languages.

```js
import { Datagrid, configure, en } from "@akinozgen17/datagrids";

// one grid
new Datagrid("#agents", { columns, messages: { empty: "No agents yet", retry: "Try again" } });

// every new grid
configure({ messages: { search: "Find…" } });
```

Overrides are partial and merged over the pack; `undefined` values never replace a string. Some
messages are functions because they include numbers, e.g.
`info: (from, to, filtered, total) => string`. The complete key list is in the
[messages reference](/reference/messages). Module strings are overridden with each module's own
`messages` option.

## Which language?

The grid resolves its locale once, at construction:

1. the `locale` option,
2. `configure({ locale })`,
3. `<html lang>`,
4. the browser's language (`navigator.language`),
5. otherwise `"en"`.

Empty values are skipped. A value the `Intl` APIs reject (`<html lang="1">`) is skipped too, with a
[DG015](/errors/DG015) warning, instead of breaking number formatting.

Locales starting with `tr` use the Turkish pack, everything else the English one. Set `<html lang>`
(you should anyway — it also drives correct uppercasing of headers) or pass `locale`.

::: code-group

```js [JavaScript]
import { Datagrid, column, tr } from "@akinozgen17/datagrids";
import { turkishRecords } from "./data.js";

// Turkish UI + Turkish collation and search folding: try searching "isik" or "ISIK"
new Datagrid("#guide-i18n-tr", {
  label: "Görev kayıtları",
  locale: "tr",
  messages: tr, // optional: "tr*" locales pick the Turkish pack automatically
  pageSize: 5,
  columns: [
    column.text("kayit", { title: "Kayıt" }),
    column.text("ad", { title: "Personel" }),
    column.text("mekan", { title: "Mekân" }),
    column.money("tutar", { title: "Tutar" }), // tr-TR, TRY
    column.date("tarih", { title: "Tarih" }),
  ],
  data: turkishRecords(60, 3),
});
```

```html [HTML]
<table id="guide-i18n-tr"></table>
```

:::

## Search and sort follow the locale

* **Search** folds case and accents with the grid's locale: `isik` finds `Işık`, `ISIK` finds
  `ışık`; every word must match (`raccoon north` → rows containing both).
* **Sorting** uses `Intl.Collator(locale, { numeric: true })`: `İ` sorts after `I`, `item 10` after
  `item 9`.
* **Numbers, money and dates** are formatted with the grid locale unless the column gets its own
  `locale`; money uses `TRY` unless you pass `currency`. Pager and info numbers use the grid locale.

## Right-to-left

The stylesheet uses logical properties only (`margin-inline-start`, `inset-inline-end`…), so a grid
inside `dir="rtl"` mirrors itself: toolbar, sort icons, sticky action column (moves to the left),
pager arrows and panels.

::: code-group

```js [JavaScript]
import { Datagrid, column } from "@akinozgen17/datagrids";
import { agents } from "./data.js";

// the grid inherits dir="rtl" from its container: logical properties mirror the layout and the pager
new Datagrid("#guide-i18n-rtl", {
  label: "RTL layout",
  locale: "en",
  pageSize: 5,
  columns: [
    column.text("ref", { title: "Ref" }),
    column.text("name", { title: "Name" }),
    column.text("unit", { title: "Unit" }), // "S.T.A.R.S. Alpha" keeps its dots in place (dir="auto")
    column.money("amount", { title: "Amount", currency: "USD", locale: "en-US" }),
  ],
  data: agents(30),
});
```

```html [HTML]
<div dir="rtl">
  <table id="guide-i18n-rtl"></table>
</div>
```

:::

Text cells are written with `dir="auto"`, so Latin data inside an RTL page keeps its punctuation in
place (`S.T.A.R.S.` doesn't become `.S.T.A.R.S`), and formatted numbers, money and dates are
bidi-isolated left-to-right blocks.

## Related

* [Messages reference](/reference/messages)
* [Theming → header style](/guide/theming#header-style-surface-and-stripes)
