Usage

Translate text with plurals

tsx
import { HStack, Symbol, Text, localization } from 'kuito';

const t = localization.messages({
  en: { inbox: '{count, plural, =0 {No messages} one {# message} other {# messages}}' },
  ar: { inbox: '{count, plural, zero {لا رسائل} one {رسالة واحدة} other {# رسائل}}' },
});

export function Inbox() {
  return (
    <HStack paddingInlineStart={16} paddingInlineEnd={8} gap={8} alignItems="center">
      <Symbol name={{ ios: 'tray', android: 'inbox' }} />
      <Text>{t('inbox', { count: 3 })}</Text>
    </HStack>
  );
}

Signatures

ts
<const C extends MessageCatalogs>(catalogs: C): (key: MessageKey<C>, values?: MessageValues) => string

Type parameters

NameConstraintDefault
CReadonly<Record<string, Readonly<Record<string, string>>>>—

Parameters

NameTypeRequiredDescription
catalogsCYes—

Returns

(key: MessageKey<C>, values?: MessageValues) => string

Generated from the public TypeScript declarations: signatures, props and defaults come from the checked source, descriptions from its JSDoc. No defaults are invented.