caique
API reference

caique/locale

Every export of caique/locale, with its signature and doc comment: checkLocales, render, sayFor, plus 2 types.

import { checkLocales, render, sayFor } from 'caique/locale';

Functions

checkLocales

R6 — refuse a pack whose caique messages cannot be rendered: an id caique does not have, a placeholder the English lacks, a plural message missing a form its locale selects. Ids that do not begin caique. are another package's and are left to it. A tag is burgee's to check, which reads it the same way; here it only has to name an object.

function checkLocales(plugin: {
    name: string;
    locales?: unknown;
}): void;
ParameterType
plugin{ name: string; locales?: unknown; }

Returns void

render

A checked message in locale, with the values put back: the plural form by count, then each {name}.

function render(message: Message, values: Readonly<Record<string, string>>, locale: string): string;
ParameterType
messageMessage
valuesReadonly<Record<string, string>>
localestring

Returns string

sayFor

function sayFor(locale: string | undefined): (english: string) => string;
ParameterType
localestring | undefined

Returns (english: string) => string

Types

Locales

A pack's locales: language tag → message id → translation. Ids outside caique. are another package's.

type Locales = Readonly<Record<string, Readonly<Record<string, Message>>>>;

Message

A translation: one string, or — for a message that carries {count} — one per plural form.

type Message = string | Readonly<Partial<Record<Intl.LDMLPluralRule, string>>>;

On this page