Skip to main content
Version: v5.3

IafViewer internationalization

Overview​

The IafViewer can show its chrome in 17 languages. Chrome covers the toolbar, tooltips, notifications, settings, model composition, cutting planes, tagged list, markup, learning center, snapshot, model tree, 2D sheets, and GIS.

The viewer ships English plus 16 other catalogs. The chrome stays in English until your application sets the i18n prop. The viewer doesn't detect the browser language (navigator.language) and doesn't support right-to-left (RTL) layouts.

The i18n prop only localizes the viewer chrome. Your application localizes the page around the viewer.

For the full prop reference, see IafViewer — i18n. IafViewerDBM forwards the same i18n prop.

Localizing the viewer​

To show the viewer chrome in another language, complete the following steps:

  1. Set i18n.locale to a host tag from the Supported locales table, for example 'ja-JP'.
  2. Optional: To change specific strings, add overrides in i18n.messages.
  3. Optional: To use your own font stack, set i18n.fontFamily.
  4. Optional: To add fonts to the markup Style dropdown, list them in i18n.fonts.
<IafViewerDBM
i18n={{
locale: 'ja-JP',
messages: { tooltips: { ResetView: 'Restore the default 3D view' } },
fonts: [{ label: 'Brand Sans', value: '"Brand Sans", system-ui, sans-serif' }],
}}
/>

The viewer applies the i18n prop on mount and whenever the prop changes. Your values override the PropertyStore defaults.

i18n props​

PropDefaultDescription
i18n.locale'en'BCP 47 tag. The language subtag selects a shipped catalog, so ja-JP selects ja. Unsupported tags and missing keys fall back to English.
i18n.messages{}Nested overrides, deep-merged onto the shipped catalog for the selected locale
i18n.fontFamilyundefinedCSS font-family stack that replaces the locale-derived stack
i18n.fonts[]Extra { label, value } font choices for the markup Style dropdown

Supported locales​

The catalog is the language. When the viewer ships the language, it keeps the region for number and date formatting. Chrome numbers use Western digits (latn).

RegionLanguageCatalogHost tagScript
—EnglishenenLatin
AsiaJapanesejaja-JPCJK
AsiaKoreankoko-KRHangul
AsiaChinese (Simplified)zhzh-CNCJK
IndiaHindihihi-INDevanagari
IndiaTelugutete-INTelugu
IndiaTamiltata-INTamil
IndiaKannadaknkn-INKannada
IndiaMarathimrmr-INDevanagari
IndiaGujaratigugu-INGujarati
IndiaMalayalammlml-INMalayalam
IndiaBengalibnbn-INBengali
EuropeGermandede-DELatin
EuropeFrenchfrfr-FRLatin
EuropeSpanisheses-ESLatin
EuropeItalianitit-ITLatin
EuropePortuguese (Brazil)ptpt-BRLatin

Message overrides​

i18n.messages is a nested object with the same shape as the English catalog. It isn't a flat map of dotted keys such as "common.confirm". Include only the keys you override, and keep any {placeholders} unchanged.

To discover the available keys, read the English catalog from IafI18n.catalog:

import { IafI18n } from "@dtplatform/iaf-viewer";
// IafI18n.catalog — stable English tree for key discovery

The catalog has these namespaces: common, tooltips, toolbar, notifications, gis, settings, composer, cuttingPlanes, taggedList, markup, learningCenter, snapshot, modelTree, viewer2d.

messages: {
common: { confirm: "OK" },
tooltips: { ResetView: "Restore the default 3D view" },
toolbar: { groups: { defaultTools: "Main tools" } },
notifications: { notifyLoadingGraphicsResources: "Loading graphics…" },
gis: { bearing: "Bearing" },
settings: { cacheSettings: "Cache settings" },
composer: { title: "Model composition" },
cuttingPlanes: { showPlanes: "Show planes" },
taggedList: { search: "Search" },
markup: { font: { system: "System" } },
learningCenter: { title: "Learning center" },
snapshot: { title: "Snapshot" },
modelTree: { toolbar: { select: "Select" } },
viewer2d: { sheetNames: "Sheet names" },
}

Fonts​

When you omit fontFamily, the viewer uses Inter, system-ui, sans-serif, plus a script hint for non-Latin locales. The viewer doesn't bundle Noto fonts.

A non-empty fontFamily replaces that stack, so include fonts that cover the script:

fontFamily: 'Inter, "Noto Sans Tamil", "Tamil Sangam MN", "Nirmala UI", Latha, system-ui, sans-serif'

The markup Style dropdown lists System (the resolved fontFamily), monospace, and arial, followed by your fonts entries. The viewer ignores entries without both label and value.

fonts: [
{ label: "Brand Sans", value: '"Brand Sans", system-ui, sans-serif' },
{ label: "Japanese", value: '"Hiragino Sans", "Noto Sans JP", sans-serif' },
]

What to localize​

LocalizeLeave as stored or in Latin script
Viewer chrome (toolbar, settings, GIS chrome, markup UI, composer display labels, cutting-plane UI, tagged list, notifications)Model _name, view titles from the model, IFC and Revit types, unit symbols
Your product wording, through messagesLayerType plugin IDs, equality keys, query tokens such as is:tagged
Discipline labels (composer.discipline.*)The English LayerType values that those labels are keyed by

Toolbar layout​

The large toolbar button is 94 × 56 px. Localized titles wrap to at most two lines inside the hover and selected highlight. The tooltip shows the full string. Don't shorten translations to match the English width.

The IafViewerExI18n example in the IafViewer Examples view shows locale switching, message overrides, and fonts.

To change the language of the Examples gallery itself, add ?locale= to its URL. This setting only affects the gallery shell. An example viewer uses it only if the example passes the i18n prop.