getLocaleEraNames
Signature
Section titled “Signature”getLocaleEraNames(locale: string, style?: LocaleNameStyle): string[]import { getLocaleEraNames } from "@northguild/gmt/plain/locale";Return a locale’s Gregorian era names as [BCE-label, CE-label].
- The two-element array is [Before Common Era label, Common Era label].
- Uses the host runtime’s
Intldata viaIntl.DateTimeFormat, so output depends on the runtime’s ICU build (full-ICU runtimes localize every locale; partial-ICU runtimes fall back to English). - If a locale has no distinct BCE/CE era names, both array elements contain the same string — the function never returns a sentinel for a valid locale, only for invalid input.
- Returns
[]iflocaleis not a valid BCP 47 tag.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
locale |
string |
BCP 47 locale tag (e.g. “en-US”, “fr-FR”, “ar-SA”) |
style |
LocaleNameStyle |
Optional name style: "long" (default), "short", or "narrow" |
Returns
Section titled “Returns”2-element [BCE-label, CE-label] array, or [] on invalid input
Related types
Section titled “Related types”Examples
Section titled “Examples”getLocaleEraNames("en-US") // ["Before Christ", "Anno Domini"]getLocaleEraNames("de-DE", "short") // ["v. Chr.", "n. Chr."]getLocaleEraNames("ja-JP", "narrow") // ["BC", "AD"]getLocaleEraNames("not-a-locale") // []