n2words icon indicating copy to clipboard operation
n2words copied to clipboard

Spanish money

Open llermaly opened this issue 3 years ago • 2 comments

Hello ,

Is there any way to customize the library to have support in some money cases like :

$1.000.000 should be "un millon de pesos"

but translates into "un millón pesos"

same with

$1.000.001 should be "un millón un peso"

Translates into "un millón uno peso"

thanks!

llermaly avatar Apr 04 '21 13:04 llermaly

Today, the library does not support currencies. We may add it in the future. Thanks for the suggestion.

forzagreen avatar Apr 04 '21 17:04 forzagreen

Hello, I applied 2 functions that fixes my problems in case somebody has the same problem as me.

Assuming you put "de pesos" after the numer in words:

//millions definition
  const isMillion = (num) => (Number.isInteger(num / 1000000) ? ' de' : '');

// uno vs un
  const isUno = (string) => string && string.replace(/uno/g, 'un');

llermaly avatar May 14 '21 08:05 llermaly