# useUiTranslation URL: /docs/native/hooks/use-ui-translation Provider-agnostic i18n bridge for Docyrus native components. Same ui.. keys as the web package, English fallback when no provider is mounted. ## Installation ```bash pnpm dlx @docyrus/cli add @docyrus/rn-hooks-use-ui-translation ``` The module exports `useUiTranslation()` (hook), `; } ``` ### Read translations in a component ```tsx import { Text } from 'react-native'; import { useUiTranslation } from '@/hooks/docyrus-native/use-ui-translation'; export function EmptyInbox() { const { t } = useUiTranslation(); return ; } ``` ### Component keys Every native component reads its built-in copy through `useUiTranslation()`; the legacy `useNativeI18n` helper, its embedded `en` / `tr` maps and the `DocyThemeProvider.messages['.']` lookup have been removed. Provide translations for the keys listed on each component page (for example `ui.alertDialog.confirm`, `ui.emptyState.searchTitle`, `ui.common.cancel`) through ``. An explicit prop (`confirmText`, `cancelLabel`, `emptyMessage`, …) always wins over the translated value. ## API Reference ### `useUiTranslation()` Takes no parameters. **Returns:** `{ t: TranslateFn }` | Field | Type | Description | |-------|------|-------------| | `t` | `(key: string, fallback: string) => string` | Translate `key`. Returns `fallback` when no provider is mounted. | ### `` | Prop | Type | Default | Description | |------|------|---------|-------------| | `t` | `(key: string, fallbackOrParams?: string \| Record) => string` | — | Required. Your i18n library's translate function. It is called as `t(key, fallback)`. | | `children` | `ReactNode` | — | Tree to wrap. | ### `UiTranslationContext` The raw React context (`{ t: TranslateFn } \| null`). It is `null` when no provider is mounted. Components normally use `useUiTranslation()` instead. ## Type Exports | Type | Description | |------|-------------| | `TranslateFn` | `(key: string, fallback: string) => string`. |