# Internationalization

- Human documentation: [https://docs.univer.ai/guides/docs/getting-started/i18n](https://docs.univer.ai/guides/docs/getting-started/i18n)

- Agent Markdown: [https://docs.univer.ai/guides/docs/getting-started/i18n.md](https://docs.univer.ai/guides/docs/getting-started/i18n.md)

- Requested language: `en-US`

- Content language: `en-US`

- Documentation version: `1.0.0-rc.0`

- Source: [docs/getting-started/i18n.mdx](https://github.com/dream-num/documentation/blob/dev/content/guides/docs/getting-started/i18n.mdx)

---

## Registering Language Packs in Preset Mode

Preset packages already include the corresponding plugin language packs, you just need to import them from the preset.

```typescript
import { UniverDocsCorePreset } from '@univerjs/preset-docs-core'
import UniverPresetDocsCoreEnUS from '@univerjs/preset-docs-core/locales/en-US' // [!code highlight]
import { createUniver, LocaleType, mergeLocales } from '@univerjs/presets'

const { univerAPI } = createUniver({
  locale: LocaleType.EN_US,
  locales: {
    [LocaleType.EN_US]: mergeLocales(
      UniverPresetDocsCoreEnUS, // [!code highlight]
    ),
  },
  presets: [
    UniverDocsCorePreset(),
  ],
})
```

## 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:

```typescript
import { LocaleType, mergeLocales, Univer } from '@univerjs/core'
import DesignEnUS from '@univerjs/design/locale/en-US' // [!code highlight]
import DocsUIEnUS from '@univerjs/docs-ui/locale/en-US' // [!code highlight]
import UIEnUS from '@univerjs/ui/locale/en-US' // [!code highlight]

const univer = new Univer({
  locale: LocaleType.EN_US,
  locales: {
    [LocaleType.EN_US]: mergeLocales(
      DesignEnUS, // [!code highlight]
      UIEnUS, // [!code highlight]
      DocsUIEnUS, // [!code highlight]
    ),
  },
})
```

> [!WARNING: Caution]
> Not all plugins include language packs. We will specify this in the documentation for each feature.

## `mergeLocales` Method

`mergeLocales` Method is used to merge multiple plugin or preset language packs into a complete language pack object. You can use it as follows:

#### Preset Mode

```typescript
import { mergeLocales } from '@univerjs/presets'

// You can pass multiple language pack objects to merge
const locales = mergeLocales(
  plugin1Locales,
  plugin2Locales,
  presetLocales,
)
// You can also pass an array of language pack objects
const locales = mergeLocales([
  plugin1Locales,
  plugin2Locales,
  presetLocales,
])
```

#### Plugin Mode

```typescript
import { mergeLocales } from '@univerjs/core'

// You can pass multiple language pack objects to merge
const locales = mergeLocales(
  plugin1Locales,
  plugin2Locales,
  presetLocales,
)
// You can also pass an array of language pack objects
const locales = mergeLocales([
  plugin1Locales,
  plugin2Locales,
  presetLocales,
])
```

## 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.

```typescript
const univer = new Univer({
  locale: 'ja-JP',
  locales: {
    'ja-JP': {
      ui: {
        shortcut: {
          undo: '元に戻す',
          redo: 'やり直す',
        },
      },
    },
  },
})
```

## Contributing Translations

Univer currently provides the following built-in language packs:

* `zh-CN`: Simplified Chinese
* `en-US`: English
* `zh-TW`: Traditional Chinese
* `zh-HK`: Traditional Chinese (Hong Kong)
* `ru-RU`: Russian
* `vi-VN`: Vietnamese
* `fa-IR`: Persian
* `fr-FR`: French
* `ja-JP`: Japanese
* `ko-KR`: Korean
* `es-ES`: Spanish
* `ca-ES`: Catalan
* `sk-SK`: Slovakian
* `ar-SA`: Arabic
* `de-DE`: German
* `id-ID`: Indonesian
* `it-IT`: Italian
* `pl-PL`: Polish
* `pt-BR`: Portuguese (Brazilian)

Univer is an open source project full of inclusiveness, and we welcome developers from all over the world to add or improve locales for Univer.
