/** * Cross-language currency-name matrix. * * One named export per *language* (not per regional/script locale), keyed by * the same minimal tag as that language's numeral entry point — camelCase, * e.g. `en` for the English family, `ptBR`/`ptPT` where the language itself * splits (see below). A language file imports only its own export, so each * per-language Rollup bundle (rollup.config.js) ships only that language's * rows via ordinary dead-code elimination on unused bindings — unlike an * object keyed the other way (ISO code -> language), where an unused * property of an exported object literal is NOT eliminated. The matrix can * grow to include any language naming any currency without affecting any * other language's bundle size. * * Word forms are plain arrays, not fixed [singular, plural] tuples: English * needs 2 forms; Czech/Polish/Croatian/Lithuanian need 3+; Japanese/Korean * need exactly 1 (no plural distinction). Which index a given amount maps * to is the language file's own pluralize()/rendering logic — that's real * per-language grammar and stays there, unchanged. `minor: null` marks a * currency with no everyday subunit (see CURRENCY_EXPONENTS below). * * `majorGender`/`minorGender` are present only for a language whose cardinal * builder takes a grammatical-gender argument (Arabic, Spanish, Slavic, * Baltic, Romanian) — see "Grammatical gender" below. * * Populated incrementally: a language ships with just its own current * default currency (a pure extraction, no new translation work); naming an * additional currency is a small, separately-reviewable addition to that * language's export — same growth model as LANGUAGE_NAME_OVERRIDES in * test/helpers/language-naming.js. * @module currency-vocab */ export type CurrencyWordForms = { /** * - Word forms for the major unit, in the language's own plural-index order */ major: string[]; /** * - Word forms for the minor unit, or null if the currency has none */ minor: string[] | null; /** * - Grammatical gender of the major-unit noun, for a gender-sensitive language */ majorGender?: ('masculine' | 'feminine'); /** * - Grammatical gender of the minor-unit noun, for a gender-sensitive language */ minorGender?: ('masculine' | 'feminine'); }; /** @satisfies {Record} */ export declare const en: { USD: { major: string[]; minor: string[]; }; CAD: { major: string[]; minor: string[]; }; AUD: { major: string[]; minor: string[]; }; NZD: { major: string[]; minor: string[]; }; SGD: { major: string[]; minor: string[]; }; GBP: { major: string[]; minor: string[]; }; EUR: { major: string[]; minor: string[]; }; BDT: { major: string[]; minor: string[]; }; GHS: { major: string[]; minor: string[]; }; INR: { major: string[]; minor: string[]; }; KES: { major: string[]; minor: string[]; }; MYR: { major: string[]; minor: string[]; }; NGN: { major: string[]; minor: string[]; }; PHP: { major: string[]; minor: string[]; }; PKR: { major: string[]; minor: string[]; }; ZAR: { major: string[]; minor: string[]; }; TND: { major: string[]; minor: string[]; }; KWD: { major: string[]; minor: string[]; }; BHD: { major: string[]; minor: string[]; }; JOD: { major: string[]; minor: string[]; }; IQD: { major: string[]; minor: string[]; }; OMR: { major: string[]; minor: string[]; }; LYD: { major: string[]; minor: string[]; }; MAD: { major: string[]; minor: string[]; }; }; /** @satisfies {Record} */ export declare const fr: { EUR: { major: string[]; minor: string[]; }; TND: { major: string[]; minor: string[]; }; MAD: { major: string[]; minor: string[]; }; }; /** @satisfies {Record} */ export declare const es: { EUR: { major: string[]; minor: string[]; majorGender: "masculine"; minorGender: "masculine"; }; MXN: { major: string[]; minor: string[]; majorGender: "masculine"; minorGender: "masculine"; }; USD: { major: string[]; minor: string[]; majorGender: "masculine"; minorGender: "masculine"; }; }; /** @satisfies {Record} */ export declare const ptBR: { BRL: { major: string[]; minor: string[]; }; USD: { major: string[]; minor: string[]; }; EUR: { major: string[]; minor: string[]; }; GBP: { major: string[]; minor: string[]; }; JPY: { major: string[]; minor: null; }; }; /** @satisfies {Record} */ export declare const ptPT: { EUR: { major: string[]; minor: string[]; }; }; /** @satisfies {Record} */ export declare const ja: { JPY: { major: string[]; minor: null; }; }; /** @satisfies {Record} */ export declare const cs: { CZK: { major: string[]; minor: string[]; }; }; /** @satisfies {Record} */ export declare const ko: { KRW: { major: string[]; minor: null; }; }; /** @satisfies {Record} */ export declare const vi: { VND: { major: string[]; minor: null; }; }; /** @satisfies {Record} */ export declare const fa: { IRR: { major: string[]; minor: null; }; }; /** @satisfies {Record} */ export declare const id: { IDR: { major: string[]; minor: null; }; }; /** @satisfies {Record} */ export declare const bn: { BDT: { major: string[]; minor: string[]; }; }; /** @satisfies {Record} */ export declare const gu: { INR: { major: string[]; minor: string[]; }; }; /** @satisfies {Record} */ export declare const hi: { INR: { major: string[]; minor: string[]; }; }; /** @satisfies {Record} */ export declare const kn: { INR: { major: string[]; minor: string[]; }; }; /** @satisfies {Record} */ export declare const mr: { INR: { major: string[]; minor: string[]; }; }; /** @satisfies {Record} */ export declare const pa: { INR: { major: string[]; minor: string[]; }; }; /** @satisfies {Record} */ export declare const ta: { INR: { major: string[]; minor: string[]; }; }; /** @satisfies {Record} */ export declare const te: { INR: { major: string[]; minor: string[]; }; }; /** @satisfies {Record} */ export declare const ur: { PKR: { major: string[]; minor: string[]; }; }; /** @satisfies {Record} */ export declare const am: { ETB: { major: string[]; minor: string[]; }; }; /** @satisfies {Record} */ export declare const amLatn: { ETB: { major: string[]; minor: string[]; }; }; /** @satisfies {Record} */ export declare const srCyrl: { RSD: { major: string[]; minor: string[]; majorGender: "masculine"; minorGender: "feminine"; }; }; /** @satisfies {Record} */ export declare const srLatn: { RSD: { major: string[]; minor: string[]; majorGender: "masculine"; minorGender: "feminine"; }; }; /** @satisfies {Record} */ export declare const zhHans: { CNY: { major: string[]; minor: string[]; }; }; /** @satisfies {Record} */ export declare const zhHant: { TWD: { major: string[]; minor: string[]; }; }; /** @satisfies {Record} */ export declare const ar: { SAR: { major: string[]; minor: string[]; minorGender: "feminine"; }; TND: { major: string[]; minor: string[]; minorGender: "masculine"; }; KWD: { major: string[]; minor: string[]; minorGender: "masculine"; }; BHD: { major: string[]; minor: string[]; minorGender: "masculine"; }; JOD: { major: string[]; minor: string[]; minorGender: "masculine"; }; IQD: { major: string[]; minor: string[]; minorGender: "masculine"; }; OMR: { major: string[]; minor: string[]; minorGender: "feminine"; }; LYD: { major: string[]; minor: string[]; minorGender: "masculine"; }; MAD: { major: string[]; minor: string[]; minorGender: "masculine"; }; }; /** @satisfies {Record} */ export declare const hbo: { ILS: { major: string[]; minor: string[]; }; }; /** @satisfies {Record} */ export declare const he: { ILS: { major: string[]; minor: string[]; }; }; /** @satisfies {Record} */ export declare const ka: { GEL: { major: string[]; minor: string[]; }; }; /** @satisfies {Record} */ export declare const hr: { EUR: { major: string[]; minor: string[]; majorGender: "masculine"; minorGender: "masculine"; }; }; /** @satisfies {Record} */ export declare const lt: { EUR: { major: string[]; minor: string[]; majorGender: "masculine"; minorGender: "masculine"; }; }; /** @satisfies {Record} */ export declare const lv: { EUR: { major: string[]; minor: string[]; majorGender: "masculine"; minorGender: "masculine"; }; }; /** @satisfies {Record} */ export declare const pl: { PLN: { major: string[]; minor: string[]; majorGender: "masculine"; minorGender: "masculine"; }; }; /** @satisfies {Record} */ export declare const ru: { RUB: { major: string[]; minor: string[]; majorGender: "masculine"; minorGender: "feminine"; }; }; /** @satisfies {Record} */ export declare const uk: { UAH: { major: string[]; minor: string[]; majorGender: "feminine"; minorGender: "feminine"; }; }; /** @satisfies {Record} */ export declare const da: { DKK: { major: string[]; minor: string[]; }; }; /** @satisfies {Record} */ export declare const de: { EUR: { major: string[]; minor: string[]; }; }; /** @satisfies {Record} */ export declare const fi: { EUR: { major: string[]; minor: string[]; }; }; /** @satisfies {Record} */ export declare const nb: { NOK: { major: string[]; minor: string[]; }; }; /** @satisfies {Record} */ export declare const nl: { EUR: { major: string[]; minor: string[]; }; }; /** @satisfies {Record} */ export declare const sv: { SEK: { major: string[]; minor: string[]; }; }; /** @satisfies {Record} */ export declare const it: { EUR: { major: string[]; minor: string[]; }; }; /** @satisfies {Record} */ export declare const ro: { RON: { major: string[]; minor: string[]; majorGender: "masculine"; minorGender: "masculine"; }; }; /** @satisfies {Record} */ export declare const az: { AZN: { major: string[]; minor: string[]; }; }; /** @satisfies {Record} */ export declare const el: { EUR: { major: string[]; minor: string[]; }; }; /** @satisfies {Record} */ export declare const fil: { PHP: { major: string[]; minor: string[]; }; }; /** @satisfies {Record} */ export declare const ha: { NGN: { major: string[]; minor: string[]; }; }; /** @satisfies {Record} */ export declare const hu: { HUF: { major: string[]; minor: string[]; }; }; /** @satisfies {Record} */ export declare const ms: { MYR: { major: string[]; minor: string[]; }; }; /** @satisfies {Record} */ export declare const sw: { KES: { major: string[]; minor: string[]; }; }; /** @satisfies {Record} */ export declare const th: { THB: { major: string[]; minor: string[]; }; }; /** @satisfies {Record} */ export declare const tr: { TRY: { major: string[]; minor: string[]; }; }; /** @satisfies {Record} */ export declare const yo: { NGN: { major: string[]; minor: string[]; }; }; /** * Currencies whose ISO 4217 minor-unit exponent is 0 — they have no everyday * subunit at all. Only these overrides are listed; an absent code is assumed * to be 2, which covers every other currency n2words names. * * **Only 0 and 3 may appear here**, and the type says so — 2 is the implicit * default for everything absent, so listing it would be noise. * * A 3 means the minor unit is a *thousandth* (millimes, fils, baisa). Such a * currency is only safe to name if the language passes * `minorUnitDigits(currency)` to `parseCurrencyValue`; parsing it at the * default 2 digits would read `'1.500'` as 50 minor units and confidently * spell "one dinar and fifty millimes" for an amount meaning five hundred. * `currency-vocab-contract.test.js` proves the round trip behaviourally for * every 3-decimal currency a language advertises, so a language that forgets * to pass the digits fails CI rather than shipping the mis-parse. This is why * `minorUnitDigits` must be called unconditionally by every `toCurrency` — * not just the languages that *currently* name a 3-decimal currency: once the * matrix is keyed by language, any entry point sharing that language's export * can reach one, including via a locale profile's delegation (see * docs/language-layers.md). * @type {Record} */ export declare const CURRENCY_EXPONENTS: Record; /** * Decimal digits `parseCurrencyValue` should track for a currency. * * Note this is *not* the ISO 4217 exponent: a zero-exponent currency returns * 2, not 0. The whole point of keeping two digits there is that * `assertCurrencyExponent` can only reject a fraction the parser bothered to * keep — parsing JPY at 0 digits would silently turn 1.5 yen into 1 yen, * which is exactly the silent truncation this package refuses to do. * @param {string} currencyCode - The resolved ISO 4217 code * @returns {number} 3 for a thousandth-unit currency, otherwise 2 */ export declare function minorUnitDigits(currencyCode: string): number; /** * Guards a currency amount against a fractional part its currency can't * represent — e.g. JPY has no everyday minor unit, so a fractional yen * amount throws rather than spelling a fictitious subunit or silently * dropping it. "Loud beats silent," the same philosophy checkMax and * resolveOptions already apply to their own preconditions. * * Scoped to what `parseCurrencyValue` measures: `cents` is the amount's * minor-unit part at that function's two-decimal precision, so this guard * fires on any fraction of 0.01 or more. A finer input (`'1.004'`) was * already truncated before arriving here and is *not* an error — see * parseCurrencyValue's "Precision" note for why two digits is the contract, * and why no supported currency can lose anything to it. * * Callers that reach a `minor: null` currency's word list rely on this: a * nonzero minor part is impossible past this point for such a currency, which * is what licenses narrowing `minor` to `string[]` inside a `cents > 0n` branch. * @param {bigint} cents - The minor-unit amount, from parseCurrencyValue * @param {string} currencyCode - The resolved ISO 4217 code * @throws {RangeError} If the currency has no minor unit and cents is nonzero */ export declare function assertCurrencyExponent(cents: bigint, currencyCode: string): void; export type AmCurrency = keyof typeof am; export type AmLatnCurrency = keyof typeof amLatn; export type ArCurrency = keyof typeof ar; export type AzCurrency = keyof typeof az; export type BnCurrency = keyof typeof bn; export type CsCurrency = keyof typeof cs; export type DaCurrency = keyof typeof da; export type DeCurrency = keyof typeof de; export type ElCurrency = keyof typeof el; export type EnCurrency = keyof typeof en; export type EsCurrency = keyof typeof es; export type FaCurrency = keyof typeof fa; export type FiCurrency = keyof typeof fi; export type FilCurrency = keyof typeof fil; export type FrCurrency = keyof typeof fr; export type GuCurrency = keyof typeof gu; export type HaCurrency = keyof typeof ha; export type HboCurrency = keyof typeof hbo; export type HeCurrency = keyof typeof he; export type HiCurrency = keyof typeof hi; export type HrCurrency = keyof typeof hr; export type HuCurrency = keyof typeof hu; export type IdCurrency = keyof typeof id; export type ItCurrency = keyof typeof it; export type JaCurrency = keyof typeof ja; export type KaCurrency = keyof typeof ka; export type KnCurrency = keyof typeof kn; export type KoCurrency = keyof typeof ko; export type LtCurrency = keyof typeof lt; export type LvCurrency = keyof typeof lv; export type MrCurrency = keyof typeof mr; export type MsCurrency = keyof typeof ms; export type NbCurrency = keyof typeof nb; export type NlCurrency = keyof typeof nl; export type PaCurrency = keyof typeof pa; export type PlCurrency = keyof typeof pl; export type PtBRCurrency = keyof typeof ptBR; export type PtPTCurrency = keyof typeof ptPT; export type RoCurrency = keyof typeof ro; export type RuCurrency = keyof typeof ru; export type SrCyrlCurrency = keyof typeof srCyrl; export type SrLatnCurrency = keyof typeof srLatn; export type SvCurrency = keyof typeof sv; export type SwCurrency = keyof typeof sw; export type TaCurrency = keyof typeof ta; export type TeCurrency = keyof typeof te; export type ThCurrency = keyof typeof th; export type TrCurrency = keyof typeof tr; export type UkCurrency = keyof typeof uk; export type UrCurrency = keyof typeof ur; export type ViCurrency = keyof typeof vi; export type YoCurrency = keyof typeof yo; export type ZhHansCurrency = keyof typeof zhHans; export type ZhHantCurrency = keyof typeof zhHant; /** * One `keyof typeof ` per language above, for that language's own * `CurrencyOptions['currency']` typedef to reference instead of hand-typing * a union. This is the enforcement half of "one named export per language": * widening a language's map (e.g. adding a currency to `en`) widens every * file that imports it and its typedef in the same edit — a typo in either * place fails typecheck instead of drifting silently out of sync with * `currencyValues`, which was already derived from `Object.keys(...)`. * @typedef {keyof typeof am} AmCurrency * @typedef {keyof typeof amLatn} AmLatnCurrency * @typedef {keyof typeof ar} ArCurrency * @typedef {keyof typeof az} AzCurrency * @typedef {keyof typeof bn} BnCurrency * @typedef {keyof typeof cs} CsCurrency * @typedef {keyof typeof da} DaCurrency * @typedef {keyof typeof de} DeCurrency * @typedef {keyof typeof el} ElCurrency * @typedef {keyof typeof en} EnCurrency * @typedef {keyof typeof es} EsCurrency * @typedef {keyof typeof fa} FaCurrency * @typedef {keyof typeof fi} FiCurrency * @typedef {keyof typeof fil} FilCurrency * @typedef {keyof typeof fr} FrCurrency * @typedef {keyof typeof gu} GuCurrency * @typedef {keyof typeof ha} HaCurrency * @typedef {keyof typeof hbo} HboCurrency * @typedef {keyof typeof he} HeCurrency * @typedef {keyof typeof hi} HiCurrency * @typedef {keyof typeof hr} HrCurrency * @typedef {keyof typeof hu} HuCurrency * @typedef {keyof typeof id} IdCurrency * @typedef {keyof typeof it} ItCurrency * @typedef {keyof typeof ja} JaCurrency * @typedef {keyof typeof ka} KaCurrency * @typedef {keyof typeof kn} KnCurrency * @typedef {keyof typeof ko} KoCurrency * @typedef {keyof typeof lt} LtCurrency * @typedef {keyof typeof lv} LvCurrency * @typedef {keyof typeof mr} MrCurrency * @typedef {keyof typeof ms} MsCurrency * @typedef {keyof typeof nb} NbCurrency * @typedef {keyof typeof nl} NlCurrency * @typedef {keyof typeof pa} PaCurrency * @typedef {keyof typeof pl} PlCurrency * @typedef {keyof typeof ptBR} PtBRCurrency * @typedef {keyof typeof ptPT} PtPTCurrency * @typedef {keyof typeof ro} RoCurrency * @typedef {keyof typeof ru} RuCurrency * @typedef {keyof typeof srCyrl} SrCyrlCurrency * @typedef {keyof typeof srLatn} SrLatnCurrency * @typedef {keyof typeof sv} SvCurrency * @typedef {keyof typeof sw} SwCurrency * @typedef {keyof typeof ta} TaCurrency * @typedef {keyof typeof te} TeCurrency * @typedef {keyof typeof th} ThCurrency * @typedef {keyof typeof tr} TrCurrency * @typedef {keyof typeof uk} UkCurrency * @typedef {keyof typeof ur} UrCurrency * @typedef {keyof typeof vi} ViCurrency * @typedef {keyof typeof yo} YoCurrency * @typedef {keyof typeof zhHans} ZhHansCurrency * @typedef {keyof typeof zhHant} ZhHantCurrency */