n2words
Version:
Convert numbers to words in 70+ languages with zero dependencies. Supports BigInt, decimals, and browser/Node.js environments.
78 lines (77 loc) • 3.09 kB
TypeScript
/**
* French (Belgium) language converter
*
* CLDR: fr-BE | French as used in Belgium
*
* Belgian French differences from standard French:
* - septante (70) instead of soixante-dix
* - nonante (90) instead of quatre-vingt-dix
* - Keeps quatre-vingts (80) like standard French
* - Uses "septante et un" (71), "nonante et un" (91)
*/
export declare const cardinalMax: bigint;
export declare const ordinalMax: bigint;
export declare const currencyMax: bigint;
export type CardinalOptions = {
/**
* - Use hyphens between words
*/
withHyphenSeparator?: boolean;
};
/**
* @typedef {object} CardinalOptions
* @property {boolean} [withHyphenSeparator] - Use hyphens between words
*/
/** @type {Required<CardinalOptions>} */
export declare const cardinalDefaults: Required<CardinalOptions>;
/**
* Converts a numeric value to Belgian French words.
* @param {number | string | bigint} value - The numeric value to convert
* @param {CardinalOptions} [options] - Optional configuration
* @returns {string} The number in Belgian French words
*/
declare function toCardinal(value: number | string | bigint, options?: CardinalOptions): string;
/**
* Converts a numeric value to Belgian French ordinal words.
*
* Belgian French ordinals: premier (1st), then cardinal + ième.
* Special rules: quatre→quatrième, cinq→cinquième, neuf→neuvième.
* @param {number | string | bigint} value - The numeric value to convert (positive integer)
* @returns {string} The number as ordinal words
* @throws {TypeError} If value is not a valid numeric type
* @throws {RangeError} If value is negative, zero, or has a decimal part
* @example
* toOrdinal(1) // 'premier'
* toOrdinal(2) // 'deuxième'
* toOrdinal(70) // 'septantième'
* toOrdinal(90) // 'nonantième'
*/
declare function toOrdinal(value: number | string | bigint): string;
export type CurrencyOptions = {
/**
* - Use "et" between euros and centimes
*/
and?: boolean;
};
/**
* @typedef {object} CurrencyOptions
* @property {boolean} [and] - Use "et" between euros and centimes
*/
/** @type {Required<CurrencyOptions>} */
export declare const currencyDefaults: Required<CurrencyOptions>;
/**
* Converts a numeric value to Belgian French currency words (Euro).
* @param {number | string | bigint} value - The currency amount to convert
* @param {CurrencyOptions} [options] - Optional configuration
* @returns {string} The amount in Belgian French currency words
* @throws {TypeError} If value is not a valid numeric type
* @throws {Error} If value is not a valid number format
* @example
* toCurrency(42.50) // 'quarante-deux euros et cinquante centimes'
* toCurrency(1) // 'un euro'
* toCurrency(0.99) // 'nonante-neuf centimes'
* toCurrency(0.01) // 'un centime'
* toCurrency(42.50, { and: false }) // 'quarante-deux euros cinquante centimes'
*/
declare function toCurrency(value: number | string | bigint, options?: CurrencyOptions): string;
export { toCardinal, toOrdinal, toCurrency };