The translation namespace (e.g., 'mfa', 'common')
Optionaloverrides: Record<string, unknown>Optional translation overrides for the namespace
An object containing the enhanced translator function and changeLanguage function
// Basic usage with namespace only
const { t, changeLanguage } = useTranslator('common');
// Usage with overrides
const { t } = useTranslator('mfa', {
title: 'Custom Title',
'sms.title': 'Text Message'
});
// Using the basic translator
const title = t('title');
const message = t('welcome', { name: 'John' });
// Using the trans method for safe HTML rendering
const elements = t.trans('help.message', {
components: {
link: (children) => <a href="/help" target="_blank">{children}</a>,
strong: (children) => <strong>{children}</strong>
},
vars: { name: 'John' }
});
// Render the elements
return (
<div>
{elements.map((element, index) => (
<Fragment key={index}>{element}</Fragment>
))}
</div>
);
// Changing language
await changeLanguage('es-ES');
Custom hook for accessing the i18n service from CoreClient.
This hook provides access to the i18n service from the CoreClient context, including enhanced translation functions with Trans component support and language change capabilities.