I18nManager
Defined in: i18n/i18n-manager.ts:33
Manages internationalization for Maya calendar terms.
Provides a registry for alternative spellings of Tzolkin day names and Haab month names, allowing parsing and rendering in different transliterations.
Example
import { I18nManager } from '@drewsonne/maya-dates';
const i18n = I18nManager.getInstance();
i18n.registerLocale({
locale: 'alt-spelling',
name: 'Alternative Spelling',
tzolkinDays: {
'Imix': { canonical: 'Imix', alternatives: ['Imix\'', 'Imix'] }
}
});
Methods
getActiveLocale()
getActiveLocale():
string
Defined in: i18n/i18n-manager.ts:142
Get the active locale
Returns
string
getRegisteredLocales()
getRegisteredLocales():
string[]
Defined in: i18n/i18n-manager.ts:149
Get all registered locales
Returns
string[]
normalizeHaabMonth()
normalizeHaabMonth(
name):string
Defined in: i18n/i18n-manager.ts:169
Normalize a Haab month name to its canonical form
Parameters
name
string
The name to normalize (may be alternative spelling)
Returns
string
The canonical name, or the input if no mapping exists
normalizeTzolkinDay()
normalizeTzolkinDay(
name):string
Defined in: i18n/i18n-manager.ts:159
Normalize a Tzolkin day name to its canonical form
Parameters
name
string
The name to normalize (may be alternative spelling)
Returns
string
The canonical name, or the input if no mapping exists
registerLocale()
registerLocale(
localeDefinition):void
Defined in: i18n/i18n-manager.ts:74
Register a new locale with its translations
Parameters
localeDefinition
The locale definition to register
Returns
void
renderHaabMonth()
renderHaabMonth(
canonicalName,locale?):string
Defined in: i18n/i18n-manager.ts:198
Get the rendering for a Haab month in the specified locale
Parameters
canonicalName
string
The canonical month name
locale?
string
The locale to render in (defaults to active locale)
Returns
string
The rendered name in the specified locale, or canonical if not found
renderTzolkinDay()
renderTzolkinDay(
canonicalName,locale?):string
Defined in: i18n/i18n-manager.ts:180
Get the rendering for a Tzolkin day in the specified locale
Parameters
canonicalName
string
The canonical day name
locale?
string
The locale to render in (defaults to active locale)
Returns
string
The rendered name in the specified locale, or canonical if not found
reset()
reset():
void
Defined in: i18n/i18n-manager.ts:212
Reset the manager to default state (for testing)
Returns
void
setActiveLocale()
setActiveLocale(
locale):void
Defined in: i18n/i18n-manager.ts:132
Set the active locale for rendering
Parameters
locale
string
The locale to activate
Returns
void
Throws
Error if locale is not registered
getInstance()
staticgetInstance():I18nManager
Defined in: i18n/i18n-manager.ts:55
Get the singleton instance of I18nManager
Returns
I18nManager