Skip to content
FrameworkStyle

Override translations

Patch individual i18n strings without replacing an entire locale pack

registerI18n merges. Each call adds or replaces translations for that locale tag without wiping prior registrations. Use this to tweak shipped packs or A/B test copy.

Read Internationalization for the translation model and merge order, and Translation keys for the supported keys.

Override after a built-in pack

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

registerI18n('es', { buttons: { play: 'Comenzar' } }); // only `buttons.play` changes

Later registrations win for the same key. The rest of the es pack stays intact.

HTML translated text

Use <media-text> for static copy outside buttons:

<media-i18n lang="es">
  <media-text token="buttons.play">Play</media-text>
</media-i18n>

The token is the lookup key and the text content is the English fallback. Override buttons.play in the registry or set lang on the provider to a locale where you patched it.

Override component text

Translation overrides change the built-in accessible labels, tooltips, and default visible text that use the same key. Set a component’s text content or children when you only need to replace its visible content.

Set text content to replace a component’s default visible text:

<media-live-button>On air</media-live-button>

Use <media-text> when authored content should still follow the active locale:

<media-live-button>
  <media-text token="live.badge">On air</media-text>
</media-live-button>

For content that changes with component state, add one <media-text> per state and show or hide them with the same state attributes used for icons:

<media-play-button>
  <media-text token="buttons.play" class="play-text">Play video</media-text>
  <media-text token="buttons.pause" class="pause-text">Pause video</media-text>
  <media-text token="buttons.replay" class="replay-text">Watch again</media-text>
</media-play-button>
.play-text,
.pause-text,
.replay-text { display: none; }

media-play-button[data-paused]:not([data-ended]) .play-text { display: inline; }
media-play-button:not([data-paused]) .pause-text { display: inline; }
media-play-button[data-ended] .replay-text { display: inline; }

This is the same state-attribute pattern used to switch icons. The token translates each fallback for the active locale.

The component still derives its accessible name from media state unless you also set its label API. Keep custom visible text consistent with that name.

Parametric translations

Keep required placeholders when overriding:

// ✅
registerI18n('es', { seek: { forward: 'Adelantar {seconds} segundos' } });

// ❌ The interpolated value is lost
registerI18n('es', { seek: { forward: 'Adelantar' } });

What’s next?