Architecture decision record · ADR-0024

Locale text

The map is in @ember-lattice/core (src/i18n/).

Status
Accepted
Deciders
Joe Gaudet
Created
Updated
PRD
PRD
Related
None

Context

AG Grid "Localisation" lets an app replace each string that the grid shows, through one map. Lattice showed English text from many packages: aria labels, live-region messages, menus, panels, filters, editors and the sheet UI. Some messages joined parts of sentences, and some tested count === 1 for a plural. The column types of @ember-lattice/column-types already take a locale, but the filters and the editors called them with no locale.

The map must reach ui, editing, charts, sheet, marquetry and later ember. These packages share only two dependencies: @ember-lattice/core and @ember-lattice/ember. Another agent edits ember now, and this change adds no package.json dependency.

Decision drivers

Not recorded in the original ADR.

Options considered

Not recorded in the original ADR.

Decision

  1. The map is in @ember-lattice/core (src/i18n/). Core has no Ember components, but it already has the Glimmer-tag atoms of ADR 0001, so it can hold reactive state with no @ember/* import. Every Lattice package imports core, so there is no cycle. ember can use the same module in phase B.
  2. One flat map with namespaced keys. DEFAULT_LOCALE_TEXT has the English defaults. A key has the form <package>.<part>.<name>, for example ui.columnMenu.sortAscending. A flat map makes a partial override simple, and the docs key table is one list. LatticeLocaleText and LatticeLocaleKey come from the map.
  3. Named params, no joins. A param is {name}. formatText fills the params, and shows a number param in the locale. The type LatticeLocaleParams<K> takes the param names from the English default, so TypeScript and Glint find a wrong param name, also in a template. Each message is one whole sentence. A date filter op has its own keys (ui.filter.dateOp.*), because "Equals" is "On" for a date.
  4. Plurals use Intl.PluralRules. A plural key has .one and .other forms. A locale can add .zero, .two, .few and .many. A missing form falls back to .other.
  5. One owner-scoped provider. setLatticeLocale(owner, { text, locale }) keeps the settings in a WeakMap from the owner to one atom. latticeLocale(owner, override?, locale?) reads them. A component gives getOwner(this). A v2 addon cannot add a service to the app with no app config, so a service is not an option. The atom read consumes its tag, so a change of the settings renders each surface that read them again. The first read makes the atom, so a later setLatticeLocale also reaches a surface that rendered before it.
  6. A @localeText arg overrides the owner text for one component. A component gives the arg to the parts that it renders (for example SideBar to ColumnsPanel and the filters). A part with a fixed signature (a Formwright control, a grid slot) reads only the owner text.
  7. Plain classes take the owner as an option. EditController takes owner and localeText. Without owner, its messages are in English. The sheet surface gets a locale function from LatticeSheet. The Marquetry sheet entry gives its own controller the owner.
  8. The locale goes to the column types. A @locale arg (or the locale option of EditController) sets the locale of one component. Without it, the owner locale applies. The condition filter, the floating filter and the editor parse read typed text in this locale. The set filter and the editor options format values in it. The grid @locale defaults to the owner locale, and goes to the cell text, the total row and the group labels.
  9. Marquetry reports are not locale text. report('Cells outside the sheet: …') goes to the model that wrote the spec, not to the DOM.

Consequences

  • An app sets the locale in one call. A test sets it on this.owner.
  • A module-level constant cannot hold a label, because it does not react to a change of the locale. Such constants now hold keys, and a getter reads the text.
  • CONDITION_OPS holds op names only. conditionOpLabel(locale, kind, op) gives the label. typeOps(type) lost its kind param. setEntries, parseFloating, parseTyped, valueParser, parserOf and sparklineLabel take an optional locale param.
  • EditController joins its two paste sentences with a space. A language that needs another join can put both counts in one sentence only with a new key. Shortcut: two plural counts in one key need a message format (ICU). Add one if a translation needs it.
  • formatText shows a number param with the default Intl.NumberFormat options. A message that needs other options formats the number first and gives it as a string.
  • Phase B moved the strings of ember to the map: grid.* (19 keys), list.loading and board.* (6 keys). LatticeGrid, LatticeList and LatticeBoard take @localeText. The board gives it to its lanes. A board message is one whole sentence with {lane}, {position} and {total} params, not a joined part.
  • rowNumberColumn and selectionColumn are plain functions with no owner. They take a locale option (a LatticeLocale). Without it, their default header is in English.
  • The default validation messages of Workbook are keys (sheet.validation.*). The model stays free of Ember: validate and setInput take an optional LatticeLocale, and the sheet surface gives its own. Without it, the messages are in English, with numbers in the workbook locale. Marquetry gives no locale: its messages go to the model in a report (item 9).
  • packages/theme has no text. The sort arrows in grid.css have empty alternative text, and aria-sort gives the state.
  • Limits: the row numbers and the lane counts show Latin digits in each locale. The header of an auto column comes from the data key with English casing. A group label with no column value shows null, as before.
  • The guide page features/locale.md has the key table, and a Vitest test (packages/core/tests/unit/locale-docs.test.ts) checks it against the map.

Confirmation

Not recorded in the original ADR.

Interview record

Each question of the interview with its answer and its source. A fact from the code or a document, a question that the author did not ask, and an assumption are rows too.

QuestionAnswerSource
Where does the text of this page come from?From the Markdown file docs/adr/0024-locale-text.md at commit 4c77ac4. The text of each section is the text of the Markdown file. A section that the Markdown file does not have says so.Document: docs/adr/0024-locale-text.md

Changelog

DateAuthorChange
2026-12-02Joe GaudetStatus in the Markdown file: accepted, 2026-12-02. Phase A and phase B are done.
2026-12-03Joe GaudetCommit 7ce4af2: Lattice 1.0 (#1)
2026-12-04Joe Gaudet (agent)Converted from docs/adr/0024-locale-text.md to this page. The text is the text of the Markdown file.

The adr skill of skillsaw wrote this page. The HTML in this file is the source of truth. The diagrams are the Mermaid sources in it.