n2words
Version:
Convert numbers to words in 70+ languages with zero dependencies. Supports BigInt, decimals, and browser/Node.js environments.
79 lines (78 loc) • 3.31 kB
TypeScript
/**
* Polish (Poland) language converter
*
* CLDR: pl-PL | Polish as used in Poland
*
* Polish-specific rules:
* - Three-form pluralization: 1 = singular, 2-4 = few, 5+ = many
* - Gender agreement (masculine/feminine for numbers < 1000)
* - Omit "jeden" before scale words (tysiąc, milion, etc.)
* - Irregular hundreds: dwieście, trzysta, czterysta, pięćset...
* - Long scale with -ard forms: miliard, biliard, tryliard
*/
export declare const cardinalMax: bigint;
export declare const ordinalMax: bigint;
export declare const currencyMax: bigint;
export type CardinalOptions = {
/**
* - Gender for numbers < 1000
*/
gender?: ('masculine' | 'feminine');
};
/**
* @typedef {object} CardinalOptions
* @property {('masculine'|'feminine')} [gender] - Gender for numbers < 1000
*/
/** @type {Required<CardinalOptions>} */
export declare const cardinalDefaults: Required<CardinalOptions>;
/** @type {{ gender: ReadonlyArray<Required<CardinalOptions>['gender']> }} */
export declare const cardinalValues: {
gender: ReadonlyArray<Required<CardinalOptions>['gender']>;
};
/**
* Converts a numeric value to Polish words.
*
* This is the main public API. It accepts any valid numeric input
* (number, string, or bigint) and handles parsing internally.
* @param {number | string | bigint} value - The numeric value to convert
* @param {CardinalOptions} [options] - Conversion options
* @returns {string} The number in Polish words
* @throws {TypeError} If value is not a valid numeric type
* @throws {Error} If value is not a valid number format
* @example
* toCardinal(1) // 'jeden'
* toCardinal(1, { gender: 'feminine' }) // 'jedna'
* toCardinal(1000) // 'tysiąc'
* toCardinal(2000) // 'dwa tysiące'
*/
declare function toCardinal(value: number | string | bigint, options?: CardinalOptions): string;
/**
* Converts a numeric value to Polish ordinal words (masculine nominative).
* @param {number | string | bigint} value - The numeric value to convert (must be a positive integer)
* @returns {string} The number as ordinal words (e.g., "pierwszy", "czterdziesty drugi")
* @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) // 'pierwszy'
* toOrdinal(2) // 'drugi'
* toOrdinal(3) // 'trzeci'
* toOrdinal(21) // 'dwudziesty pierwszy'
* toOrdinal(42) // 'czterdziesty drugi'
* toOrdinal(100) // 'setny'
* toOrdinal(1000) // 'tysięczny'
*/
declare function toOrdinal(value: number | string | bigint): string;
/**
* Converts a numeric value to Polish currency words (Polish Złoty).
* @param {number | string | bigint} value - The currency amount to convert
* @returns {string} The amount in Polish 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) // 'czterdzieści dwa złote'
* toCurrency(1) // 'jeden złoty'
* toCurrency(1.50) // 'jeden złoty pięćdziesiąt groszy'
* toCurrency(-5) // 'minus pięć złotych'
*/
declare function toCurrency(value: number | string | bigint): string;
export { toCardinal, toOrdinal, toCurrency };