Internationalization
Interface language
locale selects the language pack used for menus, tooltips, dialogs, and other translated UI. locales registers those packs without selecting one. All units in the same Univer instance share this setting. Pass LocaleType values such as LocaleType.EN_US.
- All products: UI:
localechanges translated menus, tooltips, dialogs, and plugin labels. It does not translate user content or rename existing units. - Sheets: cell formats and formulas: Cell numbers and dates render with the number-format locale override first, then the workbook snapshot
locale, then the instancelocale.regiondoes not replace any of these settings. Formula behavior such asDOLLARand the currency formats applied to financial results still useslocale, as does CJK input normalization. - Docs: statistics:
localedetermines how words are segmented and counted.
Changing language at runtime
Before switching languages, load every language pack for the installed plugins or presets. loadLocales() merges translations without switching, and setLocale() selects a language without downloading anything. A translation key with no match is displayed as the key itself. The following example loads only the shared UI pack; merge the target-language packs for the other installed plugins into the same call.
import { LocaleType, mergeLocales } from '@univerjs/core'import UIEnUS from '@univerjs/ui/locale/en-US'univerAPI.loadLocales(LocaleType.EN_US, mergeLocales(UIEnUS))univerAPI.setLocale(LocaleType.EN_US)console.log(univerAPI.getCurrentLocale()) // enUSRegistering language packs in plugin mode
In plugin mode, import the language packs from the plugins that provide them, merge them into a single object, and pass that object to the Univer instance:
import { LocaleType, mergeLocales, Univer } from '@univerjs/core'import DesignEnUS from '@univerjs/design/locale/en-US'import SheetsUIEnUS from '@univerjs/sheets-ui/locale/en-US'import UIEnUS from '@univerjs/ui/locale/en-US'const univer = new Univer({ locale: LocaleType.EN_US, locales: { [LocaleType.EN_US]: mergeLocales( DesignEnUS, UIEnUS, SheetsUIEnUS, ), },})Caution
Not every plugin includes language packs. Each feature page states whether it does.
Registering language packs in preset mode
Preset packages already contain the language packs for their plugins. Import them from the preset:
import { UniverSheetsCorePreset } from '@univerjs/preset-sheets-core'import UniverPresetSheetsCoreEnUS from '@univerjs/preset-sheets-core/locales/en-US'import { createUniver, LocaleType, mergeLocales } from '@univerjs/presets'const { univerAPI } = createUniver({ locale: LocaleType.EN_US, locales: { [LocaleType.EN_US]: mergeLocales( UniverPresetSheetsCoreEnUS, ), }, presets: [ UniverSheetsCorePreset(), ],})Merging language packs
mergeLocales merges several plugin or preset language packs into one complete language pack object:
import { mergeLocales } from '@univerjs/core'// You can pass multiple language pack objects to mergeconst locales = mergeLocales( plugin1Locales, plugin2Locales, presetLocales,)// You can also pass an array of language pack objectsconst locales = mergeLocales([ plugin1Locales, plugin2Locales, presetLocales,])import { mergeLocales } from '@univerjs/presets'// You can pass multiple language pack objects to mergeconst locales = mergeLocales( plugin1Locales, plugin2Locales, presetLocales,)// You can also pass an array of language pack objectsconst locales = mergeLocales([ plugin1Locales, plugin2Locales, presetLocales,])Custom language packs
A custom language pack can also be built. Assemble a language pack object as needed and pass it to the Univer instance. Preset language packs generally reside in the <rootDir>/packages/<PLUGIN_NAME>/locale directory.
import { LocaleType, Univer } from '@univerjs/core'const univer = new Univer({ locale: LocaleType.JA_JP, locales: { [LocaleType.JA_JP]: { ui: { shortcut: { undo: '元に戻す', redo: 'やり直す', }, }, }, },})Contributing translations
Univer currently provides the following built-in language packs:
zh-CN: Simplified Chineseen-US: Englishzh-TW: Traditional Chinesezh-HK: Traditional Chinese (Hong Kong)ru-RU: Russianvi-VN: Vietnamesefa-IR: Persianfr-FR: Frenchja-JP: Japaneseko-KR: Koreanes-ES: Spanishca-ES: Catalansk-SK: Slovakianar-SA: Arabicde-DE: Germanid-ID: Indonesianit-IT: Italianpl-PL: Polishpt-BR: Portuguese (Brazilian)
Univer is open source, and we welcome developers from anywhere to add new locales or improve the existing ones.
Regional settings
region selects the regional conventions that regional features use. All units in the same Univer instance share it.
Pass LocaleType values for both settings. For example, LocaleType.EN_US is enUS, whereas en-US is the language pack file name and BCP 47 tag. Do not pass country codes such as US or SG as region. When the UI uses a different locale, the region does not require its language pack.
Without an explicit region, the setting follows locale, including later setLocale() calls. Setting region at initialization, or calling setRegion(), stops that automatic following, and later language changes keep the selected region. No public API restores the automatic following, so update both values when they should change together.
Add region: LocaleType.DE_DE next to locale in either createUniver() or new Univer() to keep the UI language while using German regional conventions.
import { LocaleType } from '@univerjs/core'univerAPI.setRegion(LocaleType.DE_DE)univerAPI.setLocale(LocaleType.EN_US)console.log(univerAPI.getCurrentRegion()) // deDEHere the UI switches to English while regional formatting stays German. getCurrentLocale() and getCurrentRegion() return the identifiers that are actually in effect. To change both settings together, call both setters with the same LocaleType value.
- Sheets: currency controls:
regioncontrols the currency toolbar icon, the currency and accounting choices and their previews, and the format that the currency command applies. Changing it does not rewrite existing cell formats or convert monetary values. - Docs: statistics:
regionformats the counts displayed in the statistics dialog and status bar, such as grouping separators. Changingregiondoes not change the counting rules. - Thread comments, when enabled:
regioncontrols the displayed date and time format, which uses 24-hour time and Latin digits, andlocalecontrols the comment UI text. Neither changes stored timestamps, andregionis not a timezone setting. - Boards, Slides, Bases, PDFs:
localecontrols the translated UI.regionis available to shared features that consume it, such as thread comments once integrated, but it does not automatically reformat board or slide text, Base fields, or PDF content.
Right-to-left layout
Caution
RTL currently supports only the UI layer. The rendering layer does not support RTL.
Layout direction is a separate setting. Set direction at initialization, or call univerAPI.setDirection('rtl') / setDirection('ltr'). Changing locale or region alone does not switch the layout direction.
univerAPI.setDirection('rtl')How is this guide?