Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const [serialized, Serialize] = useSerialized('i18n');
const i18nDetails: I18nDetails = {
locale: givenI18nDetails.fallbackLocale || 'en',
...givenI18nDetails,
...(serialized ? serialized.i18nDetails : {}),
};
const manager = useRef(
new I18nManager(
i18nDetails,
serialized ? serialized.translations : undefined,
),
);
useHtmlAttributes({lang: i18nDetails.locale});
return (
<>
{children}
{
const getData = () => ({
translations: manager.current.extract(),
i18nDetails,
});
if (manager.current.loading) {
return manager.current.resolve().then(getData);
}
const i18nDetails: I18nDetails = {
locale: explicitI18nDetails.fallbackLocale || 'en',
...(serialized ? serialized : {}),
...explicitI18nDetails,
};
const manager = useLazyRef(
() =>
new I18nManager(
i18nDetails,
serialized ? serialized.translations : undefined,
),
).current;
useHtmlAttributes({lang: i18nDetails.locale});
const {onError, ...primitiveI18nDetails} = i18nDetails;
return (
<>
{children}
{
const getData = () => ({
translations: manager.extract(),
...primitiveI18nDetails,
});
if (manager.loading) {
return manager.resolve().then(getData);
}