# @comvi/core/icu

API reference for @comvi/core/icu: icuCompiler and the MessageCompiler type.

Canonical: https://comvi.io/docs/i18n/api/core-icu

The ICU message compiler. It goes in as the `compiler` constructor option of a
[`@comvi/core`](/docs/i18n/api/core) instance, not through `.use()`.

## Exports

- Values: `icuCompiler`.
- Types: `MessageCompiler`.

## `icuCompiler`

```ts
const icuCompiler: MessageCompiler
```

Pass it as `compiler` and ICU plural, select and selectordinal work in every catalog the
instance ingests, inline or loaded later. It is also re-exported by `@comvi/react`, `@comvi/vue`,
`@comvi/svelte`, `@comvi/solid`, `@comvi/next`, `@comvi/next/client`, `@comvi/next/server` and
`@comvi/nuxt/i18n`.

`src/icu-instance.ts`

```ts

export const i18n = createI18n({
locale: 'en',
compiler: icuCompiler,
messages: {
    en: { items: '{count, plural, one {# item} other {# items}}' },
},
});
```

## `MessageCompiler`

The shape the `compiler` option takes, also exported from the `@comvi/core` root. Type a custom
compiler with it.

## Read next

- [Pluralize with ICU](/docs/i18n/pluralization): plural, select and selectordinal per framework.
- [ICU reference](/docs/i18n/icu-reference): the grammar, what is not implemented, and the error texts.
