Skip to content

Internationalization ​

The UI ships seven built-in dictionaries: en, ja, de, fr, zh, ko, and th. Set the initial locale with locale, use instance.setLocale() for a host-owned runtime change, and override labels with strings or extend(). Dictionary changes update the mounted UI without rebuilding the spreadsheet; the complete runtime language and workbook-profile flow is covered in Language switching.

Set the initial locale ​

ts
const instance = await Spreadsheet.mount(host, {
  locale: 'en',
})

If no locale is supplied, the controller starts with the ja dictionary. Pass the locale that matches the surrounding application when the host owns language selection. For a runtime host change, use instance.setLocale() and see Language switching for the profile, formula, and failure behavior. instance.i18n.setLocale() remains the lower-level dictionary notification for dictionary or extension code.

Switch theme and locale at runtime

Change the mounted sheet’s theme and language in place. A language switch moves the UI dictionary and the calculation profile together, so function names, argument separators, and decimal marks change while the stored formula stays the same.

Powered by the real Formulon engine (WASM) — it runs entirely in your browser, nothing is uploaded.

Override labels ​

Use strings for mount-time label overrides or i18n.extend() for an update after mount. The object is a deep partial of the public Strings type.

ts
const instance = await Spreadsheet.mount(host, {
  locale: 'ja',
  strings: {
    contextMenu: {
      copy: 'コピー',
      paste: '貼り付け',
    },
  },
})

instance.i18n.extend('ja', {
  contextMenu: {
    copy: 'コピーする',
  },
})

An extend() override belongs to the locale named in the call. Switching away and back keeps that locale's override in the instance. The package dictionaries are not modified globally.

React and Vue users can pass the same strings object through the component prop. useI18n() returns the active locale and resolved dictionary for host controls that need matching labels.

Register a host locale ​

register() adds a complete dictionary under a host-defined locale id. Use the exported Strings type when building it so the dictionary stays aligned with the package declarations.

ts
import { Spreadsheet, type Strings } from '@libraz/formulon-cell'

const sv: Strings = loadSwedishDictionary()
const instance = await Spreadsheet.mount(host, { locale: 'en' })

instance.i18n.register('sv', sv)
if (!instance.setLocale('sv')) {
  showLanguageError()
}

For a small product-specific vocabulary, extending en or ja is usually simpler than maintaining a complete dictionary. A registered dictionary can be loaded from JSON or a translation bundle before setLocale(). To start a translation from a shipped dictionary, import it from @libraz/formulon-cell/i18n/en (or ja, de, fr, zh, ko, th); each module's default export is a complete Strings object.

Locale ids use their base language when resolving a built-in dictionary, so de-DE and de_brand can fall back to German labels. A custom id can provide its own dictionary, but it does not select a workbook profile; use a built-in language or region id when formula semantics must change. The zh dictionary is Simplified Chinese; a zh-TW, zh-HK, or zh-MO locale uses it for labels but selects the Traditional Chinese workbook profile, and register('zh-TW', dictionary) supplies Traditional labels. The Language switching guide lists the accepted region, script, and variant cases.

Subscribe to locale changes ​

i18n.subscribe() is useful inside an extension or a host-owned control. The spreadsheet instance also emits localeChange, which is convenient for persistence.

ts
const off = instance.on('localeChange', ({ locale }) => {
  localStorage.setItem('spreadsheet-locale', locale)
})

const saved = localStorage.getItem('spreadsheet-locale') ?? 'en'
if (!instance.setLocale(saved)) {
  showLanguageError()
}

Call the returned function when the host control is removed. Framework adapters clean up their useI18n() or useSpreadsheetEvent() subscriptions with component lifetime.

UI locale and formula display ​

The controller supplies labels for the grid controls, dialogs, menus, and extensions. Function names and descriptions shown by formula assistance can be supplied separately through WorkbookHandle.setFunctionMetadataProvider() when the application has a localized catalog. Full formula text conversion, localized input, and the boundary between UI editing and direct WorkbookHandle writes are documented in Language switching.