"undefined" in RBNF:SpelloutCardinalNeuter
rotsee opened this issue · comments
Current behaviour:
> cldr.extractRbnfFunctionByType("sv").renderSpelloutCardinalNeuter(1800000)
'en miljon åttahundraundefinedtusen noll'
Expected behaviour:
> cldr.extractRbnfFunctionByType("sv").renderSpelloutCardinalNeuter(1800000)
'en miljon åttahundratusen'
There are two, possibly related issues here: The “noll” at the end should not be there, and neither should (obviously) the word “undefined”.
The “noll” issue appears in other places too:
> cldr.extractRbnfFunctionByType("sv").renderSpelloutCardinalNeuter(1800)
'ettusen åttahundranoll'
// Expected 'ettusen åttahundra'
> cldr.extractRbnfFunctionByType("en").renderSpelloutCardinal(1800000)
'one million eight hundred zero thousand zero'
// Expected 'one million eight hundred thousand'
Sorry for all the bug reports here, they just mean that I really enjoy this library... :)
Thanks for the report and for enjoying the library :)
There's probably some kind of fundamental mistake in how the code for some of these constructs is generated. As a first step, I've made a gist with the resulting code where it's easier to single step through it: https://gist.github.com/papandreou/71a79d4c32d4cefade6a678ce80fca46
From a quick glance it seems like it starts to go wrong in line 271:
function renderSpelloutNumberingT(n) {
if (n >= 1000) return 'ERROR';
if (n >= 100)
return (
this.renderSpelloutNumbering(Math.floor(n / 100)) +
'\xADhundra' +
(n === 100 ? '' : '\xAD' + this.renderSpelloutNumberingT(n % 100)) // <-----
);
The n === 100
seems like the wrong criterion for recursing here, the logical thing would be to only call this.renderSpelloutNumberingT
when n % 100 !== 0
..
Again, I get really confused when reading the documentation while looking at