# Localization reference

> How SuperDoc matches locale to a language pack, which surfaces follow it, which value wins for a label, plural syntax, fallbacks for languages SuperDoc doesn't ship, and how keys change.







The rules behind `locale` and `translations`. To set them up, start with [Localize the Editor UI](/editor/localization).
For every key and its English text, see [Interface strings](/editor/localization/interface-strings).

## Language matching [#language-matching]

SuperDoc matches each tag in `locale`, in order:

1. A pack for the exact tag, such as `pt-BR`.
2. A pack for the tag without its region, keeping the script: `zh-Hant-TW` matches `zh-Hant`.
3. A pack for the base language: `pt-PT` matches `pt`.

A `translations` entry for a language SuperDoc does not ship counts as a pack for this matching. If no pack matches a tag,
SuperDoc tries the next one. If none match, it uses English.

If a pack has no text for a label, SuperDoc shows the English text for that label.

## The `lang` attribute [#the-lang-attribute]

When `locale` is set, SuperDoc puts the chosen language in the `lang` attribute of each built-in UI surface, so screen
readers pronounce its labels in that language. Text that comes from the document or from other people, such as comment
bodies, author names, tracked-change excerpts, and custom style names, gets `lang=""` (unknown). Without `locale`,
SuperDoc adds no `lang` attribute.

## Coverage [#coverage]

> **Diagram:** A sketch of the Editor that numbers each surface that follows locale: toolbar, popups, search, context menu, comments, tracked-change labels, dialogs, and header and footer labels.


| Area                                                   | Follows `locale` |
| ------------------------------------------------------ | ---------------- |
| Toolbar, its dropdowns, and the style list             | Yes              |
| Link, page-number, and AI writer popups                | Yes              |
| Watermark dialog and presets                           | Yes              |
| Context menu and its panels                            | Yes              |
| Comments, the comments list, and comment timestamps    | Yes              |
| Search and replace                                     | Yes              |
| Table, bookmark, and cross-reference dialogs           | Yes              |
| Loading screen and header and footer labels            | Yes              |
| Tracked-change labels in review cards and lists        | Yes              |
| Accessible names of links, text boxes, and line breaks | Yes              |

Built-in style names follow `locale`, as Word shows them: `heading 1` appears as **Título 1** in Portuguese and
Spanish. Custom style names stay as the document stores them.

## Which value wins [#which-value-wins]

For each label, SuperDoc uses the first value that is set:

> **Diagram:** Four sources checked in order: the surface option, such as ui.toolbar.strings; translations for the chosen language; the language pack chosen from locale; and English.


1. The surface's own option, such as `ui.toolbar.strings`, `ui.toolbar.texts`, or `ui.search.strings`, for the text
   that option controls.
2. `translations` for the chosen language.
3. The language pack for `locale`.
4. English.

A surface option covers only the text it controls. For most toolbar buttons, such as Bold, `ui.toolbar.strings` and
`ui.toolbar.texts` set only the tooltip, and the accessible name still comes from `translations` or the pack; to change
both for Bold, set `toolbar.bold` in `translations`. The Watermark, Page number, and Comments layout buttons use the
toolbar text for both, so a `ui.toolbar.strings` value for them also wins for their accessible name.

Existing per-surface options keep working unchanged. Use `translations` when you want one place for labels across
surfaces. The per-surface options use different keys for the same text: `ui.toolbar.strings['font-family']` and
`translations.en['toolbar.fontFamily']` set the same tooltip. The
[Toolbar](/editor/built-in-ui/configure-the-toolbar#change-toolbar-text) and
[Search](/editor/built-in-ui/search-and-replace#change-search-text) pages list how their keys map.

A watermark preset inserts the text its button shows, so a `translations` value for `watermark.presetDraft`,
`watermark.presetConfidential`, or `watermark.presetDoNotCopy` also changes the text the preset inserts. See
[Watermarks](/editor/built-in-ui/watermarks).

## Invalid entries [#invalid-entries]

At runtime, SuperDoc ignores a `translations` entry whose outer key is not a valid language tag and logs a warning.

A value that uses a `{placeholder}` the English text does not have, such as `{nome}` where English has `{name}`, logs a
warning: SuperDoc never fills it, so it shows as written.

## Labels with a count [#labels-with-a-count]

Some labels include a number, such as `comments.moreReplies` ("3 more replies") and the tracked-change labels for list
items. Their values use ICU plural syntax, so each language chooses the right word form for the count:

```ts
const translations = {
  'pt-BR': {
    'comments.moreReplies': '{count, plural, =0 {Sem respostas} one {Mais # resposta} other {Mais # respostas}}',
  },
} satisfies SuperDocTranslations;
```

* `{count, plural, ...}` lists one form per plural category: `zero`, `one`, `two`, `few`, `many`, and `other`. The
  browser's `Intl.PluralRules` picks the category with the rules of the language the text is written in: a label
  that falls back to English uses English rules. Every plural needs an `other` form. A form the language never uses,
  such as `few` in Portuguese, logs a warning and is kept.
* `=0`, `=1`, `=1.5`, and other `=N` forms match one exact number and take precedence over the category.
* `#` is the count, formatted for the language: `1.000` in Portuguese. Inside a form, `#` always means the count.
* A form can contain other `{placeholders}`, such as `{name}`.
* Apostrophes are plain text; SuperDoc does not use ICU's apostrophe quoting. Braces that do not start a placeholder,
  such as `{INTERNAL USE}`, are also plain text; inside a form, open and close them in pairs.

SuperDoc supports `plural` only, not `select`, `selectordinal`, or number and date formats. If a `translations` value is
not valid plural syntax, SuperDoc ignores it, logs a warning, and shows the pack's text.

## Languages SuperDoc doesn't ship [#languages-superdoc-doesnt-ship]

A `translations` entry for a language SuperDoc does not ship adds that language; see
[Add a language SuperDoc doesn't ship](/editor/localization#add-a-language-superdoc-doesnt-ship).

* `locale` matches your entry the same way it matches a pack: `fr-CA` uses a `fr` entry. Dates and numbers follow the
  full tag, `fr-CA`.
* A label your entry does not translate shows the text SuperDoc would show for that tag without your entry: the pack for
  the same language, with its own `translations` entry, or English when SuperDoc ships none. A `pt-PT` entry falls back
  to Brazilian Portuguese; a `fr` entry falls back to English, including your `translations.en` values.
* Each label your entry is missing logs one warning, the first time SuperDoc shows it.
* Plural labels use the rules of your language: `{count, plural, one {...} other {...}}` picks French forms for `fr`,
  where `0` is `one`. See [Labels with a count](#labels-with-a-count).
* In a list such as `locale: ['fr', 'pt-BR']`, the first language with an entry or a pack wins, even if your `fr` entry
  has one label. Missing labels then fall back to English, not to the next language in the list.
* The interface's `lang` attribute is your tag, so screen readers read every label in that language, including labels
  that fell back to English. Translate every label your interface shows to avoid mixed-language text.

## When keys change [#when-keys-change]

The keys are part of SuperDoc's public API. Within a major version, SuperDoc only adds keys. If a key is renamed, the
old name keeps working until the next major version, and SuperDoc logs a warning that names the new key. Keys are
removed only in a major version. To find the keys a version added, compare its `en.json` with the previous version's;
see [Find keys a new version added](/editor/localization/interface-strings#find-keys-a-new-version-added).
