Internationalization

GitHubEdit on GitHub

Registering Language Packs in Preset Mode

Preset packages already include the corresponding plugin language packs, you just need to 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, merge } from '@univerjs/presets'

const { univerAPI } = createUniver({
  locale: LocaleType.EN_US,
  locales: {
    [LocaleType.EN_US]: merge(
      {},
      UniverPresetSheetsCoreEnUS,
    ),
  },
  presets: [
    UniverSheetsCorePreset(),
  ],
})

Registering Language Packs in Plugin Mode

To register language packs in plugin mode, you need to import the corresponding language packs from the plugins that provide them and merge them into a single object to pass to the Univer instance. Here is an example:

import { LocaleType, merge, 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]: merge(
      {},
      DesignEnUS,
      UIEnUS,
      SheetsUIEnUS,
    ),
  },
})

Caution

Not all plugins include language packs. We will specify this in the documentation for each feature.

Custom Language Packs

Univer also supports custom language packs. You can assemble a language pack object as needed and pass it to the Univer instance. The preset language packs are generally stored in the <rootDir>/packages/<PLUGIN_NAME>/locale directory.

const univer = new Univer({
  locale: 'es-ES',
  locales: {
    'es-ES': {
      shortcut: {
        undo: 'Deshacer',
        redo: 'Rehacer',
      },
    },
  },
})

Contributing Translations

Univer currently provides the following built-in language packs:

  • zh-CN: Simplified Chinese
  • en-US: English
  • zh-TW: Traditional Chinese
  • ru-RU: Russian
  • vi-VN: Vietnamese
  • fa-IR: Persian
  • fr-FR: French
  • ko-KR: Korean

Univer OSS is an open source project full of inclusiveness, and we welcome developers from all over the world to add or improve locales for Univer. If you are interested in contributing locales to Univer, please refer to the Contribution Guide.

How is this guide?