Skip to content

Referencei18n

registerI18n

Register or merge translation strings for a BCP 47 locale tag in the global i18n registry

Import

import { registerI18n } from "@videojs/html/i18n";

registerI18n merges a partial translation map into the process-wide registry for a locale tag. Components carry their own English fallback text. Built-in non-English packs lazy-load automatically; call registerI18n for custom locales, CDN locale modules, or patched shipped packs before the provider renders.

Keys are nested semantic names such as buttons.play and buttons.pause. See Translation phrases for the complete catalog.

import { registerI18n } from '@videojs/html/i18n';

registerI18n('es', {
  buttons: {
    play: 'Reproducir',
    pause: 'Pausar',
  },
});

Built-in locale packs

Each shipped pack is a module named after its locale tag. Its default export is the pack’s Translations map. Pass it to registerI18n when you load a pack yourself, for example right before switching to that locale:

import { registerI18n } from '@videojs/html/i18n';
import ja from '@videojs/html/i18n/locales/ja';

registerI18n('ja', ja);

A side-effect import of the pack’s /register subpath, such as import '@videojs/html/i18n/locales/ja/register', does the same.

API Reference

registerI18n(locale, translations): void

Parameters

ParameterTypeDefaultDetails
locale*(typeof LOCALES)[number] | string & {}—
translations*Partial<Translations>—

Return Value

void