papandreou / inter

A JavaScript locale library based on information extracted from the Unicode CLDR database
BSD 3-Clause "New" or "Revised" License
21 stars 5 forks source link

Wrong spellout cardinal for et locale #6

Closed ragulka closed 10 years ago

ragulka commented 10 years ago
console.log(inter.renderSpelloutCardinal(2439871));

Gives: üks miljonit nelisada ükskümmend üheksa tuhat kolmkümmend üks

The above result is totally messed up. It should say: kaks miljonit nelisada kolmkümmend üheksa tuhat kaheksasada seitsekümmend üks

Basically, translated to english, it is currently saying: One millione four-hunderd onety-nine-thousand thrity-one

I guess there must be a serious flaw in the cardinal function generator.

ragulka commented 10 years ago

FWIW, here are some more errors that I stumbled when trying it out.

var inter = require('inter').load('fr_be');
console.log(inter.renderSpelloutCardinal(2439871));

Results in:

TypeError: Cannot call method 'charCodeAt' of undefined
    at subformatFixed (/Library/WebServer/Documents/node_projects/test_inter/node_modules/inter/build/root.js:175:121)
    at format (/Library/WebServer/Documents/node_projects/test_inter/node_modules/inter/build/root.js:350:84)
    at Object.(anonymous function) [as renderNumber] (/Library/WebServer/Documents/node_projects/test_inter/node_modules/inter/build/root.js:573:162)
    at Object.inter.renderSpelloutCardinal (/Library/WebServer/Documents/node_projects/test_inter/node_modules/inter/build/fr_be.js:856:33)

The following:

var inter = require('inter').load('fr');
console.log(inter.renderSpelloutCardinal(2439871));

Results in:

2 439 871
papandreou commented 10 years ago

Thanks for taking the time to submit these issues. Some of them are certainly caused by me rushing the update to CLDR 24 without realizing that there were major changes. I'm really sorry about that. I managed to fix some of the problems, but I haven't released a new version yet, because I started writing tests and realized that more stuff is broken.

I hope I'll find the time to get the project into a good state soon. Thanks for you patience.

ragulka commented 10 years ago

That's okay. I was simply playing around. I do hope I can evaluate your lib for an app that I am building, where i18n is a big must.

papandreou commented 10 years ago

Seems like these are now fixed in inter 1.2.3, which will be released shortly (updates cldr to 2.1.1).

Apparently the correct name for that spellout rule is spelloutNumbering, not spelloutCardinal. Seems like spelloutCardinal only exists as a helper function in some locales as of some CLDR update.

require('inter').load('fr_be').renderSpelloutNumbering(2439871);
// 'deux millions quatre cent trente-neuf mille huit cent septante-et-un'

And for fr:

require('inter').load('fr').renderSpelloutNumbering(2439871);
// 'deux millions quatre cent trente-neuf mille huit cent soixante-et-un'

Better?