UNPKG

@hebcal/hdate

Version:

converts between Hebrew and Gregorian dates using Rata Die (R.D.) algorithm by Dershowitz and Reingold

80 lines (79 loc) 3.08 kB
export interface Headers { 'content-type'?: string; 'plural-forms'?: string; } export type StringArrayMap = Record<string, string[]>; export interface LocaleData { headers: Headers; contexts: { [key: string]: StringArrayMap; }; } /** * A locale in Hebcal is used for translations/transliterations of * holidays. `@hebcal/hdate` supports four locales by default * * `en` - default, Sephardic transliterations (e.g. "Shabbat") * * `ashkenazi` - Ashkenazi transliterations (e.g. "Shabbos") * * `he` - Hebrew (e.g. "שַׁבָּת") * * `he-x-NoNikud` - Hebrew without nikud (e.g. "שבת") */ export declare class Locale { /** * Returns translation only if `locale` offers a non-empty translation for `id`. * Otherwise, returns `undefined`. * @param id Message ID to translate * @param [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale. */ static lookupTranslation(id: string, locale?: string): string | undefined; /** * By default, if no translation was found, returns `id`. * @param id Message ID to translate * @param [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale. */ static gettext(id: string, locale?: string): string; /** * Register locale translations. * @param locale Locale name (i.e.: `'he'`, `'fr'`) * @param data parsed data from a `.po` file. */ static addLocale(locale: string, data: LocaleData): void; /** * Adds a translation to `locale`, replacing any previous translation. * @param locale Locale name (i.e: `'he'`, `'fr'`). * @param id Message ID to translate * @param translation Translation text */ static addTranslation(locale: string, id: string, translation: string | string[]): void; /** * Adds multiple translations to `locale`, replacing any previous translations. * @param locale Locale name (i.e: `'he'`, `'fr'`). * @param data parsed data from a `.po` file. */ static addTranslations(locale: string, data: LocaleData): void; /** * Activates a locale. Throws an error if the locale has not been previously added. * After setting the locale to be used, all strings marked for translations * will be represented by the corresponding translation in the specified locale. * @param locale Locale name (i.e: `'he'`, `'fr'`) * @deprecated */ static useLocale(locale: string): StringArrayMap; /** * Returns the name of the active locale (i.e. 'he', 'ashkenazi', 'fr') * @deprecated */ static getLocaleName(): string; /** * Returns the names of registered locales */ static getLocaleNames(): string[]; /** * Renders a number in ordinal, such as 1st, 2nd or 3rd * @param [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale. */ static ordinal(n: number, locale?: string): string; /** * Removes nekudot from Hebrew string */ static hebrewStripNikkud(str: string): string; }