Internationalization
Interface language
locale selects the language pack used for menus, tooltips, dialogs, and other translated UI text. locales registers language packs without selecting one. The setting is shared by the units in the Univer instance. Use LocaleType values, such as LocaleType.EN_US.
- All products: UI:
localechanges the language of menus, tooltips, dialogs, and plugin labels. It does not translate user content or rename existing units. - Sheets: cell formats and formulas: Number and date rendering in a cell resolves through the number-format locale override first, then the workbook snapshot
locale, and finally the instancelocale.regiondoes not replace any of them. Formula behavior such asDOLLARand currency formats in financial results still useslocale, and CJK input normalization also useslocale. - Docs: statistics:
localedetermines word segmentation and counting.
Changing language at runtime
Load the language packs of every installed plugin and preset before switching languages. loadLocales() merges translations without switching languages; setLocale() selects a language but downloads nothing. A missing translation key is displayed as the key itself. The example below loads the shared UI pack; the target-language packs of other installed plugins must be merged in 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()) // enUSMerging language packs
mergeLocales combines the language packs of several plugins or presets 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
Univer also supports custom language packs. Assemble a language pack object as needed and pass it to the Univer instance. The preset language packs are usually stored in <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 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 all over the world to add or improve locales.
Regional settings
region selects the regional conventions that region-aware features follow. The setting is shared by the units in the Univer instance.
Both settings take a LocaleType value. For example, LocaleType.EN_US is enUS, while en-US is the language-pack file name and the BCP 47 tag. Do not pass a country code such as US or SG as region. A region does not need its own language pack when the UI uses a different locale.
Without an explicit region, it follows locale, including later setLocale() calls. Setting region during initialization, or calling setRegion(), stops this automatic following. After that, language changes leave the region unchanged. No public API restores the following behavior, so update both values when they should change together.
To keep the UI language while using German regional conventions, add region: LocaleType.DE_DE next to locale in createUniver() or new Univer().
import { LocaleType } from '@univerjs/core'univerAPI.setRegion(LocaleType.DE_DE)univerAPI.setLocale(LocaleType.EN_US)console.log(univerAPI.getCurrentRegion()) // deDEHere the UI is in English while regional formatting remains German. getCurrentLocale() and getCurrentRegion() return the identifiers in effect. To change both at once, call both setters with the same LocaleType value.
- Sheets: currency controls:
regioncontrols the currency icon in the toolbar, the currency and accounting choices 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 numbers shown in the statistics dialog and the status bar, including grouping separators. Changingregiondoes not change the counting rules. - Thread comments, when enabled:
regioncontrols the date and time format that comments display, with 24-hour time and Latin digits.localecontrols 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 reformat board or slide text, Base fields, or PDF content.
Right-to-left layout
Caution
RTL currently covers the UI layer only. The rendering layer does not support it yet.
Caution
Not every plugin includes a language pack. The documentation for each feature states whether it does.
univerAPI.setDirection('rtl')How is this guide?