n2words
Version:
Convert numbers to words in 70+ languages with zero dependencies. Supports BigInt, decimals, and browser/Node.js environments.
73 lines (72 loc) • 2.92 kB
TypeScript
/**
* Latvian (Latvia) language converter
*
* CLDR: lv-LV | Latvian as used in Latvia
*
* Key features:
* - Two-form pluralization (singular for 1 except 11, plural otherwise)
* - Gender agreement (masculine/feminine for numbers < 1000)
* - Special hundreds forms (simts/simti/simtu)
* - Omit "one" before scale words
* - Long scale naming
*/
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 Latvian words.
* @param {number | string | bigint} value - The numeric value to convert
* @param {CardinalOptions} [options] - Conversion options
* @returns {string} The number in Latvian words
* @throws {TypeError} If value is not a valid numeric type
* @throws {Error} If value is not a valid number format
* @example
* toCardinal(42) // 'četrdesmit divi'
* toCardinal(1, { gender: 'feminine' }) // 'viena'
* toCardinal(1000) // 'tūkstotis'
*/
declare function toCardinal(value: number | string | bigint, options?: CardinalOptions): string;
/**
* Converts a numeric value to Latvian 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
* @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) // 'pirmais'
* toOrdinal(2) // 'otrais'
* toOrdinal(21) // 'divdesmit pirmais'
* toOrdinal(100) // 'simtais'
* toOrdinal(1000) // 'tūkstošais'
*/
declare function toOrdinal(value: number | string | bigint): string;
/**
* Converts a numeric value to Latvian currency words (Euro).
* @param {number | string | bigint} value - The currency amount to convert
* @returns {string} The amount in Latvian 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) // 'četrdesmit divi eiro'
* toCurrency(1) // 'viens eiro'
* toCurrency(1.50) // 'viens eiro piecdesmit centu'
* toCurrency(-5) // 'mīnus pieci eiro'
*/
declare function toCurrency(value: number | string | bigint): string;
export { toCardinal, toOrdinal, toCurrency };