GuidesUniver SheetsGet StartedInternationalization

Internationalization

Presets Installation

Each Preset provides a corresponding locale, import the locale corresponding to the Preset you are using:

import { createUniver, defaultTheme, LocaleType, merge } from '@univerjs/presets';
import { UniverSheetsCorePreset } from '@univerjs/presets/preset-sheets-core';
import UniverPresetSheetsCoreEnUS from '@univerjs/presets/preset-sheets-core/locales/en-US';
import { UniverSheetsAdvancedPreset } from '@univerjs/presets/preset-sheets-advanced';
import UniverPresetSheetsAdvancedEnUS from '@univerjs/presets/preset-sheets-advanced/locales/en-US';
import { UniverSheetsDrawingPreset } from '@univerjs/presets/preset-sheets-drawing'
import UniverPresetSheetsDrawingZhCN from '@univerjs/presets/preset-sheets-drawing/locales/zh-CN'
 
import '@univerjs/presets/lib/styles/preset-sheets-core.css'
import '@univerjs/presets/lib/styles/preset-sheets-drawing.css'
import '@univerjs/presets/lib/styles/preset-sheets-advanced.css'
 
const { univerAPI } = createUniver({
  locale: LocaleType.EN_US,
  locales: {
    [LocaleType.EN_US]: merge(
      {},
      UniverPresetSheetsCoreEnUS,
      UniverPresetSheetsDrawingEnUS,
      UniverPresetSheetsAdvancedEnUS,
    ),
  },
  theme: defaultTheme,
  presets: [
    UniverSheetsCorePreset(),
    UniverSheetsDrawingPreset(),
    UniverSheetsAdvancedPreset(),
  ],
});

Piecemeal Installation

From version 0.1.13, Univer no longer includes any locales, all locales are provided by plugins.

If you need to manually add locales, you can refer to the following example, import the corresponding locale as needed and assemble it into an object to pass it to the Univer instance:

import { LocaleType, merge, Univer } from '@univerjs/core';
import { defaultTheme } from "@univerjs/design";
import DesignEnUS from '@univerjs/design/locale/en-US';
import UIEnUS from '@univerjs/ui/locale/en-US';
import DocsUIEnUS from '@univerjs/docs-ui/locale/en-US';
import SheetsEnUS from '@univerjs/sheets/locale/en-US';
import SheetsUIEnUS from '@univerjs/sheets-ui/locale/en-US';
import SheetsNumfmtUIEnUS from '@univerjs/sheets-numfmt-ui/locale/en-US';
import SheetsFormulaUIEnUS from '@univerjs/sheets-formula-ui/locale/en-US';
 
const univer = new Univer({
  theme: defaultTheme,
  locale: LocaleType.EN_US,
  locales: {
    [LocaleType.EN_US]: merge(
      {},
      DesignEnUS,
      UIEnUS,
      DocsUIEnUS,
      SheetsEnUS,
      SheetsUIEnUS,
      SheetsNumfmtUIEnUS
      SheetsFormulaUIEnUS,
    ),
  },
});

Using Custom Locales

Univer also supports custom locales, you can assemble the locale object according to your needs and pass it to the Univer instance. The preset locales for reference are generally stored in the <rootDir>/packages/<PLUGIN_NAME>/locale directory.

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

Contributing Translations

Now, Univer includes the following preset locales:

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

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.


Was this page helpful?