CLDR logic in Javascript