Created
December 6, 2013 17:25
-
-
Save rxaviers/7828731 to your computer and use it in GitHub Desktop.
Change example for https://github.com/santhoshtr/CLDRPluralRuleParser if they consider using CLDR in the JSON form, and using [cldr.js](https://github.com/rxaviers/cldr). NOTE: THIS IS A PSEUDO CODE CHANGE. IT HAS NOT BEEN TESTED
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/CLDRPluralRuleParser.js b/src/CLDRPluralRuleParser.js | |
index b533f2c..a18e47a 100755 | |
--- a/src/CLDRPluralRuleParser.js | |
+++ b/src/CLDRPluralRuleParser.js | |
@@ -467,7 +467,19 @@ function pluralRuleParser(rule, number) { | |
return result; | |
} | |
+function plural(localeString, number) { | |
+ var form; | |
+ var locale = new Cldr(localeString); | |
+ var rules = locale.supplemental("plurals-type-cardinal/{language}"); | |
+ for(form in rules) { | |
+ if(pluralRuleParser(rules[form], number)) { | |
+ return form; | |
+ } | |
+ } | |
+ throw new Error('Ops!'); | |
+} | |
+ | |
/* For module loaders, e.g. NodeJS, NPM */ | |
if (typeof module !== 'undefined' && module.exports) { | |
- module.exports = pluralRuleParser; | |
-} | |
\ No newline at end of file | |
+ module.exports = plural; | |
+} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment