Skip to content

Referencei18n

loadLocale

Lazy-load the built-in translation pack for a locale

Import

import { loadLocale } from "@videojs/react/i18n";

loadLocale imports the built-in pack for a tag, or for the closest tag in its findLocaleKeys chain, and resolves to its flat translations. It resolves to undefined when that chain reaches a locale registered with registerI18n first, or when no built-in pack matches. Providers call it for you; use it to translate UI outside a provider without bundling every pack.

import { createTranslator, getI18nTranslations, loadLocale } from '@videojs/react/i18n';

const pack = await loadLocale('fr-CA');
const t = createTranslator({ ...pack, ...getI18nTranslations('fr-CA') }, 'fr-CA');

t('buttons.play'); // 'Lecture'

API Reference

loadLocale(tag): Promise<Partial<FlatTranslations> | undefined>

Parameters

ParameterTypeDefaultDetails
tag*string—

Return Value

TypeDetails
Promise<Partial<FlatTranslations> | u...