Methods

(static) loadChineseLocaleFile(locale) → {object}

Load Chinese locale translations with script code layering. Chinese locales use script codes (Hans=Simplified, Hant=Traditional) instead of region codes. The loader reads a base zh.json first, but none ships under locale/custom/, so that layer is empty. The layers in effect: zh_Hans: zh_Hans.json zh_Hant: zh_Hant.json zh_Hant_HK: zh_Hant.json -> zh_Hant_HK.json

Parameters:
NameTypeDescription
localestring

Chinese locale code (for example "zh_Hans", "zh_Hant", "zh_Hant_HK")

Returns:

Parsed roAssociativeArray, or invalid if no file found

Type: 
object

(static) loadLocaleFile(locale) → {object}

Load a locale's translations, layering regional over base when applicable. For regional locales (for example "fr_CA"), loads the base language ("fr") first, then overlays regional translations on top. Regional values win on conflicts. For Chinese script codes (for example "zh_Hant_HK"), hands off to loadChineseLocaleFile(), which layers zh_Hant under zh_Hant_HK. For base locales (for example "fr"), loads directly.

Parameters:
NameTypeDescription
localestring

Locale code (for example "fr_CA", "de", "zh_Hans", "zh_Hant_HK")

Returns:

Parsed roAssociativeArray, or invalid if no file found

Type: 
object

(static) loadTranslations(locale) → {void}

Load translation files for a given locale into m.global. Always loads en_US as fallback. When the active locale is en_US, both m.global.translations and m.global.translationsFallback are set from the same AA.

Parameters:
NameTypeDescription
localestring

Locale code in standard format (for example "fr_CA", "pt_BR", "zh_Hans")

Returns:
Type: 
void

(static) translate(key, paramsopt) → {string}

Translate a key, optionally substituting indexed placeholders {0}, {1}, etc. Falls back to en_US if key is missing from active locale, or returns the key itself if missing from both (makes untranslated strings visible during dev).

Parameters:
NameTypeAttributesDefaultDescription
keystring

Translation key (for example "ButtonPlay", "MessageCastCanceled")

paramsobject<optional>
invalid

Optional array of string replacements for {0}, {1}, etc.

Returns:

Translated string, or the key itself if not found

Type: 
string

(static) translateCached(key, cache) → {string}

translateCached: translate(), memoized for one batch.

Memoized on the KEY rather than on the item: a batch labels many items with a few distinct keys, and keying on the item would miss on every one (see personCreditLabel in people.bs). cache may be invalid, which only means no reuse.

A caller may instead seed cache with the table itself (m.global.translations, read once), so every key it holds is already a hit and a missing one still falls back through translate(). Which seed is cheaper depends on how many distinct keys the batch needs. The cast needs a few, and copying the ~150 KB table on every row cost MORE than the memo (measured 2026-09-20 on a Stick 4K, 31-person cast: castMs +13.5 ms, n=8 per arm interleaved; a build making ZERO m.global reads was no faster again, so the rendezvous is not what that loop costs). A subtitle list needs a language name per track, often dozens, so sortSubtitles() copies the table once per list instead.

Parameters:
NameTypeDescription
keystring
cachedynamic
Returns:
Type: 
string

(static) translatePlural(baseKey, count, paramsopt) → {string}

Translate a plural key using zero/one/many suffix convention. Selects the appropriate variant based on count, then delegates to translate().

Parameters:
NameTypeAttributesDefaultDescription
baseKeystring

Base key without suffix (for example "LabelEpisodeCount")

countinteger

The count to determine plural form

paramsobject<optional>
invalid

Optional placeholder params

Returns:

Translated plural string

Type: 
string