Usage
Returns a translator function that resolves keys against the current locale, provider overrides, and the shipped English fallback catalog. Call inside a component; the returned function can be used anywhere within that component's scope.
tsimport {useTranslator} from '@astryxdesign/core/i18n'
Returns
| Field | Type | Description |
|---|---|---|
| value | (key: string, values?: Record<string, string | number | Date>) => string | A stable translator function bound to the current InternationalizationProvider context. Call it with a message key and optional ICU MessageFormat values to get the formatted string in the active locale. Safe to use in render, event handlers, effects, or any code that runs during the parent component's lifecycle. |
Examples
Common configurations, variations, and states.A "Load more" footer under a list that gets its button label and its "Showing 3 of 9" count from the function useTranslator returns, with app message keys supplied per locale through InternationalizationProvider, so switching the provider to French changes both strings.
Use with shadcn
Already using the shadcn registry workflow? Install the real Astryx package and a local public re-export. Component implementation source stays in Astryx.
This install URL expires with the draft preview.bashnpx shadcn@4.19.0 add https://astryx-1lfixy8sw-fbopensource.vercel.app/shadcn/hooks/use-translator.json