Closed mwoc closed 8 years ago
It would add value to node-cldr if the extract function could just return those particular values as regxeps. https://github.com/One-com/unicoderegexp could be a help here as it contains categories as character classes, and some utilities for composing them.
That would be analogous to extractRbnfFunctionByType
and extractPluralRuleFunction
returning functions instead of the actual data, which is hard to consume.
I think I would try that first and see if it fits.
I've pushed some code to https://github.com/papandreou/inter/tree/feature/currencySpacing, which is experimental and not working, but would take the regexes from node-cldr. Somehow they end up as empty object when inter builds them though, I suppose inter doesn't support putting a regex directly into the json?
It comes out like:
currency: {
"default": "¤ #,##0.00",
other: "{0} {1}",
currencySpacing: {
beforeCurrency: {
currencyMatch: {},
surroundingMatch: {},
insertBetween: " "
},
afterCurrency: {
currencyMatch: {},
surroundingMatch: {},
insertBetween: " "
}
}
},
Oh, it's the https://github.com/papandreou/node-uglifyast/tree/master/lib that doesn't support regular expressions when converting back and forth between objects and ASTs. Let's fix that tomorrow.
This landed on v1.9.0
In CLDR, there is a currencySpacing section available, which has the same content for each number system and locale. This information is being made available by node-cldr now: https://github.com/papandreou/node-cldr/commit/a31ab1659a37bb09055df24765781141a2fc726e
In currencySpacing, there's a regex "[:^S:]", which according to this page stands for Symbol: http://unicode.org/glossary/#graphic_character
In the case of currencySpacing, we could limit its range to just currency symbols: http://unicode.org/charts/PDF/U20A0.pdf
We could expand [:^S:] to: /[^\u20a0-\u20cf \u0024 \u00a2-\u00a5 \u0192 \u058f \u060b \u09f2 \u09f3 \u0af1 \u0bf9 \u0e3f \u17db \u2133 \u5143 \u5186 \u5706 \u5713 \ufdfc]/
@papandreou do you agree with doing such an expansion in inter, or would it fit better in node-cldr?