Internationalization
Interface language
locale selects the language pack used for menus, tooltips, dialogs, and other translated UI. locales registers language packs without selecting one. Every unit in the Univer instance shares these settings. Pass LocaleType values, for example LocaleType.EN_US.
- All products: UI:
localechanges the translated menus, tooltips, dialogs, and plugin labels. It does not modify user content or rename existing units. - Sheets: cell formats and formulas: Numbers and dates render with the number-format locale override first, then the workbook snapshot
locale, and then the instancelocale.regiondoes not replace any of these. Formula behavior, such asDOLLARand the currency formats applied to financial results, still followslocale, and CJK input normalization also useslocale. - Docs: statistics:
localedetermines word segmentation and counting.
Changing language at runtime
Before switching languages, load every language pack that the installed plugins or presets provide. loadLocales() merges translations without switching the language; setLocale() switches to the loaded translations without downloading anything. A key without a translation appears as the key itself. The following example loads the shared UI language pack. Add the target-language packs for the other installed plugins to the same merge 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 pack from each plugin that provides one, 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 DocsUIEnUS from '@univerjs/docs-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, DocsUIEnUS, ), },})Caution
Not every plugin includes a language pack. Each feature's documentation states whether it does.
Registering language packs in preset mode
Preset packages already include the language packs of their plugins, so they can be imported directly from the preset:
import { UniverDocsCorePreset } from '@univerjs/preset-docs-core'import UniverPresetDocsCoreEnUS from '@univerjs/preset-docs-core/locales/en-US'import { createUniver, LocaleType, mergeLocales } from '@univerjs/presets'const { univerAPI } = createUniver({ locale: LocaleType.EN_US, locales: { [LocaleType.EN_US]: mergeLocales( UniverPresetDocsCoreEnUS, ), }, presets: [ UniverDocsCorePreset(), ],})Merging language packs
mergeLocales merges multiple plugin or preset language packs into a single complete language pack object. Use it as follows:
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 assembled manually. Build the required object and pass it to the Univer instance. For reference, preset language packs are usually stored under <rootDir>/packages/<PLUGIN_NAME>/locale.
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 includes 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 contributions that add or improve a language pack are welcome.
Regional settings
region determines the regional conventions that regional features follow. Units in the Univer instance share this setting.
Both settings take LocaleType values. For example, LocaleType.EN_US is enUS, while en-US is the language-pack file name and the BCP 47 tag. Do not pass country codes such as US or SG as region. A region does not require its language pack when the UI uses a different locale.
When region is not set explicitly, it follows locale, including subsequent setLocale() calls. Setting region at initialization or calling setRegion() stops this automatic following. Language changes after that keep the selected region. There is no public API to restore automatic following, so update both values when they should change together.
To keep the UI language while applying German regional conventions, add region: LocaleType.DE_DE next to locale in either createUniver() or new Univer().
import { LocaleType } from '@univerjs/core'univerAPI.setRegion(LocaleType.DE_DE)univerAPI.setLocale(LocaleType.EN_US)console.log(univerAPI.getCurrentRegion()) // deDEIn this example, the UI switches to English and regional formatting stays German. getCurrentLocale() and getCurrentRegion() return the effective identifiers. To change both together, call both setters with the same LocaleType value.
- Sheets: currency controls:
regiondetermines the currency toolbar icon, the currency and accounting options and their previews, and the pattern that the currency command applies. Changing it does not rewrite existing cell formats or convert monetary values. - Docs: statistics:
regionformats the counts shown in the statistics dialog and status bar, including grouping separators. Changingregiondoes not change the counting rules. - Thread comments, when enabled:
regioncontrols the date and time format shown in comments, using 24-hour time and Latin digits.localecontrols comment UI text. Neither setting changes stored timestamps, andregionis not a timezone setting. - Boards, Slides, Bases, PDFs:
localecontrols translated UI.regionapplies to shared features that consume it, such as thread comments once integrated; it does not automatically reformat board or slide text, Base fields, or PDF content.
Right-to-left layout
Caution
RTL is currently supported only in 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') or setDirection('ltr'). Changing locale or region alone does not switch the layout direction.
univerAPI.setDirection('rtl')How is this guide?