Skip to Content
Headless SDKHooksLocalization

Localization Hooks

Hooks for translations and locale detection.

useTranslation()

Access the translation system. Re-renders when the locale changes.

const { t, locale, setLocale, availableLocales } = useTranslation() return ( <div> <h1>{t('welcome', { name: 'John' })}</h1> <button onClick={() => setLocale('de')}>Deutsch</button> </div> )
PropertyTypeDescription
t(key: string, params?: Record<string, string | number>) => stringTranslate a key with optional interpolation
localestringCurrent active locale
setLocale(locale: string) => voidSwitch locale at runtime
availableLocalesstring[]Locales with loaded translations

useLocale()

Read the browser’s locale information. Computed once on mount.

const { language, region, timeZone, is24Hour } = useLocale()
PropertyTypeDescription
localestringFull locale string (e.g. "en-US")
languagestringLanguage code (e.g. "en")
regionstringRegion code (e.g. "US")
languagesstring[]All preferred languages from navigator.languages
timeZonestringIANA timezone (e.g. "America/New_York")
is24HourbooleanWhether the locale uses 24-hour clock
Last updated on