Skip to content

Feature: Internationalization #222

Description

@mihar-22

Implement internationalization (i18n) support for Video.js 10 — translated aria-labels, tooltips, time unit strings, and dialog copy, plus locale-aware Intl formatting. Works with or without a provider by inheriting the native HTML lang attribute, keeps skins presentation-only, and ships CDN-compatible locale modules.

Design doc: internal/design/i18n.md (status: implemented)

Goals

  • Opaque camelCase keysplay, seekForward, etc. English strings live in en.ts as values, not keys
  • Global registryregisterI18n(locale, translations) is the single entry point; locale files are ES modules that self-register
  • Ambient <html lang> inheritance — providers read the native lang attribute; zero config for the common case
  • Decoupled from skins — skins are i18n-unaware; providers distribute context, components auto-forward labels via I18nController
  • Typed keysTranslator enforces per-key param shapes via overloaded signatures and Contains<> template literals
  • CDN-compatible — locale files are self-registering ES modules with no global namespace pollution
  • Locale-aware formatting — native Intl.DurationFormat, Intl.NumberFormat, Intl.PluralRules handle time, percent, and plural selection

PR stack (merge order)

Each PR stacks on the previous. All are open and ready for review.

# PR Branch Closes
1 #1589 feat/i18n-core #1363
2 #1590 feat/i18n-locale-packs #1368, #1369
3 #1591 feat/i18n-html #1365, #1367
4 #1595 feat/i18n-react #1364
5 #1593 feat/i18n-sandbox #1594
6 #1600 docs/i18n #1373
PR 1 — Core foundation (#1589)
  • @videojs/core/i18n registry, translator, en.ts, browser Translation API fallback
  • Locale DOM helpers + formatDuration in @videojs/utils
  • Opaque translation keys across core UI components
PR 2 — Locale packs (#1590)
  • ~50 v8-parity locale packs, loadLocale, codegen, CDN locale stubs
  • Workspace check:workspace i18n consistency
PR 3 — HTML layer (#1591)
  • createI18n(), I18nController, <media-text>, CDN i18n entry
  • Control wiring and error dialog i18n helpers
PR 4 — React layer (#1595)
  • createI18n(), I18nProvider, useTranslator, preset wiring
PR 5 — Sandbox (#1593)
  • Locale picker on all presets, shared helpers, e2e coverage
PR 6 — Docs (#1600)
  • Concept page, how-to guides, API/util reference pages, sidebar wiring

Sub-issues

Issue Tracks
#1363 Core types, registry, translator
#1368 Built-in locale packs
#1369 CDN i18n/locale build
#1365 HTML i18n layer
#1364 React i18n layer
#1594 Sandbox demos + e2e
#1373 Site docs

Absorbed / out of scope

Architecture overview

@videojs/core/i18n
  Translations · Translator · createTranslator · loadLocale
  registerI18n · getI18nTranslations · onI18nRegistryChange
  Registry (singleton Map) · en.ts (base layer, always present)
        │
        ├── @videojs/react/i18n
        │     createI18n() → { I18nProvider, useTranslator, useLocale }
        │
        └── @videojs/html/i18n
              createI18n() → { I18nController, ProviderMixin, TextMixin }
              <media-i18n-provider lang="es">, <media-text key="play">
              MediaButtonElement uses I18nController → auto-forwards aria-labels

Metadata

Metadata

Assignees

Fields

No fields configured for Enhancement.

Projects

Status
Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions