Skip to content
Comvi

@comvi/core/icu

View .md

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

  • Values: icuCompiler.
  • Types: MessageCompiler.
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
import { createI18n } from '@comvi/core';
import { icuCompiler } from '@comvi/core/icu';
export const i18n = createI18n({
locale: 'en',
compiler: icuCompiler,
messages: {
en: { items: '{count, plural, one {# item} other {# items}}' },
},
});

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