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.
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. Module strings are overridden with each module's own messages option.
Which language?
The grid resolves its locale once, at construction:
- the
localeoption, configure({ locale }),<html lang>,- the browser's language (
navigator.language), - otherwise
"en".
Empty values are skipped. A value the Intl APIs reject (<html lang="1">) is skipped too, with a 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.
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),
});<table id="guide-i18n-tr"></table>Search and sort follow the locale
- Search folds case and accents with the grid's locale:
isikfindsIşık,ISIKfindsışık; every word must match (raccoon north→ rows containing both). - Sorting uses
Intl.Collator(locale, { numeric: true }):İsorts afterI,item 10afteritem 9. - Numbers, money and dates are formatted with the grid locale unless the column gets its own
locale; money usesTRYunless you passcurrency. 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.
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),
});<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.