{
  "title": "useTranslation",
  "description": "Read i18n keys with interpolation and pluralization. Drives every visible string in the library.",
  "url": "/docs/hooks/use-translation",
  "since": "0.0.1",
  "tags": [
    "hooks",
    "i18n"
  ],
  "platform": "both",
  "source": "---\ntitle: useTranslation\ndescription: Read i18n keys with interpolation and pluralization. Drives every visible string in the library.\nsince: 0.0.1\ntags: [hooks, i18n]\nplatform: both\ncategory: hooks\n---\n\nThe library's i18n primitive. Every visible string in `@nori-ui/core` is sourced through this hook — overriding a key in your `<NoriProvider i18n={…}>` rewires every component that uses it.\n\n## Usage\n\n```tsx\nimport { useTranslation } from '@nori-ui/core/client';\n\nfunction GreetButton({ name }: { name: string }) {\n    const { t } = useTranslation();\n    return <button type=\"button\">{t('greet.hello', { name, defaultValue: 'Hello, {{name}}' })}</button>;\n}\n```\n\n## API\n\n### Returns\n\n| Name | Type | Description |\n|---|---|---|\n| `t` | `(key: string, options?: { defaultValue?: string; count?: number; [k: string]: unknown }) => string` | Resolve a key against the current dictionary. Falls back to `defaultValue` if the key is missing. |\n| `language` | `string` | Active BCP 47 locale (read-only). |\n\n## Behavior notes\n\n- **Interpolation** uses `{{name}}` syntax — double braces, no spaces.\n- **Pluralization** follows i18next conventions: `count`-based suffixes (`_zero`, `_one`, `_two`, `_few`, `_many`, `_other`).\n- **`defaultValue`** is required for every call by convention — it documents the fallback inline and keeps your translation files self-describing.\n- **Missing keys** return `defaultValue` and emit a dev warning so missing translations are visible in development.\n\n## Adding a custom dictionary\n\n```tsx\nimport { NoriProvider } from '@nori-ui/core/client';\n\n<NoriProvider i18n={{ en: { 'pagination.next': 'More results →' } }}>\n    {children}\n</NoriProvider>\n```\n\nKeys you don't override fall through to the library default dictionary.\n\n## Related\n\n- [Theming](/docs/theming) — the sibling provider.\n"
}
