Constants
Language codes, names, and configuration constants.
Import from @workspace/i18n/constants.
ALL_LANGUAGE_CODES
The complete list of language codes supported across the monorepo. Individual apps define subsets of these codes.
import { ALL_LANGUAGE_CODES } from '@workspace/i18n/constants';
ALL_LANGUAGE_CODES;
// ["ca", "de", "en", "es", "fr", "it", "nl", "pl", "pt", "sv", "el"]LanguageCode
Union type derived from ALL_LANGUAGE_CODES. Use this as the base type for language-related parameters.
import type { LanguageCode } from '@workspace/i18n/constants';
// "ca" | "de" | "en" | "es" | "fr" | "it" | "nl" | "pl" | "pt" | "sv" | "el"
const lang: LanguageCode = "fr";Lang
Enum-like constant object for type-safe language references. Avoids typos when referencing language codes.
import { Lang } from '@workspace/i18n/constants';
Lang.FR; // "fr"
Lang.EN; // "en"
Lang.DE; // "de"| Key | Value |
|---|---|
Lang.CA | "ca" |
Lang.DE | "de" |
Lang.EN | "en" |
Lang.ES | "es" |
Lang.FR | "fr" |
Lang.IT | "it" |
Lang.NL | "nl" |
Lang.PL | "pl" |
Lang.PT | "pt" |
Lang.SV | "sv" |
Lang.EL | "el" |
LANGUAGE_NAMES
Maps each language code to its native name. Used for display in UI components.
import { LANGUAGE_NAMES } from '@workspace/i18n/constants';
LANGUAGE_NAMES.fr; // "Français"
LANGUAGE_NAMES.en; // "English"
LANGUAGE_NAMES.el; // "Ελληνικά"OG_LOCALES
Maps each language code to its OpenGraph locale format (language_TERRITORY). Used for meta tags and social sharing.
import { OG_LOCALES } from '@workspace/i18n/constants';
OG_LOCALES.fr; // "fr_FR"
OG_LOCALES.en; // "en_US"
OG_LOCALES.pt; // "pt_PT"STORAGE_KEY
The localStorage key used to persist the user's language preference.
import { STORAGE_KEY } from '@workspace/i18n/constants';
STORAGE_KEY; // "preferred-language"toPlayerLang
Converts a language code to the code expected by the legacy player, which uses "gr" instead of the standard "el" for Greek. Every other code is returned unchanged.
import { toPlayerLang } from '@workspace/i18n/constants';
toPlayerLang("el"); // "gr"
toPlayerLang("fr"); // "fr"WORLD_LANGUAGE_CODES
Every ISO 639-1 two-letter language code (about 180 entries), with its WorldLanguageCode union type. It is a static replacement for Intl.supportedValuesOf("language"), whose browser support is inconsistent. Use it for content languages (e.g. the language of an imported deal), not for UI languages. Exported from the root entry only.
import { WORLD_LANGUAGE_CODES, type WorldLanguageCode } from '@workspace/i18n';
(WORLD_LANGUAGE_CODES as readonly string[]).includes(lang);