Skip to content
FrameworkStyle

createI18n

Factory that creates framework i18n helpers with custom loading options

createI18n returns a context-bound ProviderMixin, TextMixin, and I18nController for custom elements. Use it when you need a custom locale loader or custom i18n elements. Most apps use <media-i18n> and <media-text> from @videojs/html/i18n.

import { ReactiveElement } from '@videojs/element';
import { createI18n } from '@videojs/html/i18n';

const { ProviderMixin, TextMixin } = createI18n();

class LocalizedRoot extends ProviderMixin(ReactiveElement) {}
class LocalizedText extends TextMixin(ReactiveElement) {}

API Reference

Parameters

ParameterTypeDefaultDetails
optionsCreateI18nOptions

Return Value

PropertyTypeDetails
I18nContextContext<I18nContextValue | null>
I18nProviderfunction
useTranslatoruseTranslator
useLocaleuseLocale