Skip to content

Referencei18n

getLocaleKey

Normalize a locale tag to the key the i18n registry stores it under

Import

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

getLocaleKey lowercases a BCP 47 tag, replaces underscores with hyphens, and removes Unicode extensions such as -u-nu-latn. The registry stores registerI18n layers under this key, so use it to compare a tag with one you have registered or to key your own per-locale data the same way.

import { getLocaleKey } from '@videojs/react/i18n';

getLocaleKey('en_US-u-nu-latn'); // 'en-us'
getLocaleKey('zh-Hant'); // 'zh-hant'

API Reference

getLocaleKey(locale): Locale

Parameters

ParameterTypeDefaultDetails
locale*(typeof LOCALES)[number] | string & {}—

Return Value

(typeof LOCALES)[number] | string & {}