--- id: localization-provider title: description: Mount translations into a subtree. --- # `` ```ts import { LocalizationProvider } from 'localize-react'; ``` ## Props | Prop | Type | Default | Description | | -------------- | -------------- | ------- | ------------------------------------------------------------------------------------------------ | | `locale` | `string` | — | Locale key inside `translations`. If omitted, `translations` is treated as the flat lookup tree. | | `translations` | `Translations` | `{}` | Required. Nested object; leaves are strings. | | `disableCache` | `boolean` | `false` | Bypass the internal memo cache. Use during dev when mutating translations in place. | | `children` | `ReactNode` | — | The subtree that will see this context. | ## Example ```tsx import { LocalizationProvider } from 'localize-react'; const translations = { en: { hello: 'Hi {{name}}!' }, fr: { hello: 'Salut {{name}} !' }, }; ; ``` ## Switching the locale at runtime There's no global mutable state — just rerender the provider: ```tsx function Shell({ children }: { children: React.ReactNode }) { const [locale, setLocale] = React.useState('en'); return ( {children} ); } ``` The internal cache is rebuilt on every locale or translations change, discarding the previous entries. ## Stacking providers You can mount more than one provider — descendants see the nearest. Useful for tests or for swapping a subtree's locale without rerendering the rest. Each provider keeps its **own** translate cache, so nested or sibling providers with overlapping descriptors never serve each other's strings: ```tsx
``` ## See also - [`useLocalize()`](./use-localize) — read the value. - [``](./message) — component form of `translate`. - [Locale resolution guide](../guides/locale-resolution).