Wrap intl in span identifying translation

This commit is contained in:
Jamie Curnow committed 2025-10-02 23:06:51 +10:00
1 parent fcb08d3003
commit 227e818040
68 files changed
+1076 -510

No files matched your search

+7 -1
View File
@@ -61,4 +61,10 @@ const changeLocale = (locale: string): void => {
document.documentElement.lang = locale;
};
export { localeOptions, getFlagCodeForLocale, getLocale, createIntl, changeLocale, intl };
// This is a translation component that wraps the translation in a span with a data
// attribute so devs can inspect the element to see the translation ID
const T = ({ id, data }: { id: string; data?: any }) => {
return <span data-translation-id={id}>{intl.formatMessage({ id }, data)}</span>;
};
export { localeOptions, getFlagCodeForLocale, getLocale, createIntl, changeLocale, intl, T };