mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
27 lines
876 B
TypeScript
27 lines
876 B
TypeScript
import { ensureSandboxLocale } from '@app/shared/i18n/sandbox-locales';
|
|
import { I18nProvider } from '@videojs/react/i18n';
|
|
import { type ReactNode, useEffect } from 'react';
|
|
|
|
import { useLocale } from './use-locale';
|
|
|
|
function syncHtmlLang(locale: string): void {
|
|
if (typeof document === 'undefined' || document.documentElement.lang === locale) return;
|
|
document.documentElement.lang = locale;
|
|
}
|
|
|
|
/** Composes React i18n and syncs `<html lang>` for sandbox locale demos. */
|
|
export function SandboxI18nProvider({ children }: { children: ReactNode }) {
|
|
const locale = useLocale();
|
|
|
|
syncHtmlLang(locale);
|
|
|
|
useEffect(() => {
|
|
syncHtmlLang(locale);
|
|
void ensureSandboxLocale(locale).catch(() => {
|
|
// I18nProvider still lazy-loads registry packs when prefetch fails.
|
|
});
|
|
}, [locale]);
|
|
|
|
return <I18nProvider locale={locale}>{children}</I18nProvider>;
|
|
}
|