twitter_cldr 3.0.10 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -2
- data/History.txt +9 -0
- data/README.md +8 -0
- data/Rakefile +1 -1
- data/lib/twitter_cldr.rb +1 -1
- data/lib/twitter_cldr/data_readers/number_data_reader.rb +60 -8
- data/lib/twitter_cldr/formatters/numbers/abbreviated/abbreviated_number_formatter.rb +3 -11
- data/lib/twitter_cldr/formatters/numbers/number_formatter.rb +5 -12
- data/lib/twitter_cldr/formatters/numbers/rbnf.rb +2 -1
- data/lib/twitter_cldr/formatters/numbers/rbnf/formatters.rb +4 -1
- data/lib/twitter_cldr/formatters/numbers/rbnf/plural.rb +49 -0
- data/lib/twitter_cldr/formatters/numbers/rbnf/rule.rb +4 -3
- data/lib/twitter_cldr/formatters/numbers/rbnf/rule_parser.rb +12 -1
- data/lib/twitter_cldr/formatters/numbers/rbnf/substitution.rb +1 -1
- data/lib/twitter_cldr/formatters/plurals/rules.rb +26 -10
- data/lib/twitter_cldr/localized/localized_number.rb +2 -15
- data/lib/twitter_cldr/resources/download.rb +3 -3
- data/lib/twitter_cldr/resources/locales_resources_importer.rb +24 -16
- data/lib/twitter_cldr/resources/uli/segment_exceptions_importer.rb +1 -1
- data/lib/twitter_cldr/shared/postal_codes.rb +30 -2
- data/lib/twitter_cldr/tokenizers/numbers/rbnf_tokenizer.rb +2 -1
- data/lib/twitter_cldr/version.rb +1 -1
- data/resources/locales/af/calendars.yml +44 -29
- data/resources/locales/af/currencies.yml +300 -603
- data/resources/locales/af/languages.yml +22 -359
- data/resources/locales/af/lists.yml +8 -8
- data/resources/locales/af/numbers.yml +74 -25
- data/resources/locales/af/plural_rules.yml +7 -0
- data/resources/locales/af/plurals.yml +13 -3
- data/resources/locales/af/territories.yml +7 -7
- data/resources/locales/ar/calendars.yml +25 -11
- data/resources/locales/ar/currencies.yml +115 -229
- data/resources/locales/ar/languages.yml +39 -124
- data/resources/locales/ar/lists.yml +12 -12
- data/resources/locales/ar/numbers.yml +170 -25
- data/resources/locales/ar/plural_rules.yml +11 -0
- data/resources/locales/ar/plurals.yml +18 -6
- data/resources/locales/be/calendars.yml +10 -20
- data/resources/locales/be/currencies.yml +40 -778
- data/resources/locales/be/languages.yml +2 -447
- data/resources/locales/be/lists.yml +3 -15
- data/resources/locales/be/numbers.yml +26 -26
- data/resources/locales/be/plural_rules.yml +9 -0
- data/resources/locales/be/plurals.yml +17 -7
- data/resources/locales/be/rbnf.yml +15 -105
- data/resources/locales/be/territories.yml +5 -16
- data/resources/locales/bg/calendars.yml +61 -40
- data/resources/locales/bg/currencies.yml +147 -176
- data/resources/locales/bg/languages.yml +56 -149
- data/resources/locales/bg/lists.yml +5 -5
- data/resources/locales/bg/numbers.yml +73 -24
- data/resources/locales/bg/plural_rules.yml +7 -0
- data/resources/locales/bg/plurals.yml +13 -3
- data/resources/locales/bg/territories.yml +10 -10
- data/resources/locales/bn/calendars.yml +43 -29
- data/resources/locales/bn/currencies.yml +156 -253
- data/resources/locales/bn/languages.yml +61 -150
- data/resources/locales/bn/lists.yml +4 -4
- data/resources/locales/bn/numbers.yml +74 -25
- data/resources/locales/bn/plural_rules.yml +11 -0
- data/resources/locales/bn/plurals.yml +19 -3
- data/resources/locales/bn/territories.yml +35 -35
- data/resources/locales/ca/calendars.yml +38 -23
- data/resources/locales/ca/currencies.yml +285 -63
- data/resources/locales/ca/languages.yml +12 -76
- data/resources/locales/ca/lists.yml +4 -4
- data/resources/locales/ca/numbers.yml +74 -25
- data/resources/locales/ca/plural_rules.yml +10 -0
- data/resources/locales/ca/plurals.yml +17 -4
- data/resources/locales/ca/territories.yml +20 -20
- data/resources/locales/cs/calendars.yml +33 -18
- data/resources/locales/cs/currencies.yml +397 -118
- data/resources/locales/cs/languages.yml +109 -90
- data/resources/locales/cs/numbers.yml +121 -24
- data/resources/locales/cs/plural_rules.yml +9 -0
- data/resources/locales/cs/plurals.yml +16 -6
- data/resources/locales/cs/territories.yml +2 -2
- data/resources/locales/cy/calendars.yml +4 -5
- data/resources/locales/cy/currencies.yml +56 -424
- data/resources/locales/cy/languages.yml +210 -379
- data/resources/locales/cy/lists.yml +1 -5
- data/resources/locales/cy/numbers.yml +170 -25
- data/resources/locales/cy/plural_rules.yml +16 -0
- data/resources/locales/cy/plurals.yml +26 -4
- data/resources/locales/cy/rbnf.yml +8 -8
- data/resources/locales/da/calendars.yml +28 -13
- data/resources/locales/da/currencies.yml +135 -136
- data/resources/locales/da/languages.yml +10 -74
- data/resources/locales/da/numbers.yml +73 -24
- data/resources/locales/da/plural_rules.yml +7 -0
- data/resources/locales/da/plurals.yml +13 -4
- data/resources/locales/da/territories.yml +2 -2
- data/resources/locales/de-CH/calendars.yml +29 -15
- data/resources/locales/de-CH/currencies.yml +327 -101
- data/resources/locales/de-CH/languages.yml +112 -83
- data/resources/locales/de-CH/numbers.yml +73 -24
- data/resources/locales/de-CH/plural_rules.yml +7 -0
- data/resources/locales/de-CH/plurals.yml +13 -4
- data/resources/locales/de-CH/territories.yml +3 -3
- data/resources/locales/de/calendars.yml +29 -15
- data/resources/locales/de/currencies.yml +328 -101
- data/resources/locales/de/languages.yml +112 -83
- data/resources/locales/de/numbers.yml +73 -24
- data/resources/locales/de/plural_rules.yml +7 -0
- data/resources/locales/de/plurals.yml +13 -4
- data/resources/locales/de/rbnf.yml +189 -0
- data/resources/locales/de/territories.yml +3 -3
- data/resources/locales/el/calendars.yml +30 -16
- data/resources/locales/el/currencies.yml +144 -91
- data/resources/locales/el/languages.yml +8 -72
- data/resources/locales/el/numbers.yml +73 -24
- data/resources/locales/el/plural_rules.yml +7 -0
- data/resources/locales/el/plurals.yml +13 -3
- data/resources/locales/el/territories.yml +1 -1
- data/resources/locales/en-150/calendars.yml +15 -5
- data/resources/locales/en-150/currencies.yml +49 -9
- data/resources/locales/en-150/languages.yml +99 -70
- data/resources/locales/en-150/numbers.yml +73 -24
- data/resources/locales/en-150/plural_rules.yml +10 -0
- data/resources/locales/en-150/plurals.yml +18 -4
- data/resources/locales/en-150/territories.yml +15 -15
- data/resources/locales/en-AU/calendars.yml +21 -11
- data/resources/locales/en-AU/currencies.yml +69 -29
- data/resources/locales/en-AU/languages.yml +101 -72
- data/resources/locales/en-AU/lists.yml +1 -1
- data/resources/locales/en-AU/numbers.yml +73 -24
- data/resources/locales/en-AU/plural_rules.yml +10 -0
- data/resources/locales/en-AU/plurals.yml +18 -4
- data/resources/locales/en-AU/territories.yml +19 -19
- data/resources/locales/en-CA/calendars.yml +18 -8
- data/resources/locales/en-CA/currencies.yml +49 -9
- data/resources/locales/en-CA/languages.yml +99 -70
- data/resources/locales/en-CA/numbers.yml +74 -25
- data/resources/locales/en-CA/plural_rules.yml +10 -0
- data/resources/locales/en-CA/plurals.yml +18 -4
- data/resources/locales/en-CA/territories.yml +15 -15
- data/resources/locales/en-GB/calendars.yml +21 -8
- data/resources/locales/en-GB/currencies.yml +242 -55
- data/resources/locales/en-GB/languages.yml +102 -73
- data/resources/locales/en-GB/lists.yml +1 -1
- data/resources/locales/en-GB/numbers.yml +74 -25
- data/resources/locales/en-GB/plural_rules.yml +10 -0
- data/resources/locales/en-GB/plurals.yml +18 -4
- data/resources/locales/en-GB/territories.yml +5 -5
- data/resources/locales/en-IE/calendars.yml +12 -2
- data/resources/locales/en-IE/currencies.yml +49 -9
- data/resources/locales/en-IE/languages.yml +99 -70
- data/resources/locales/en-IE/numbers.yml +74 -25
- data/resources/locales/en-IE/plural_rules.yml +10 -0
- data/resources/locales/en-IE/plurals.yml +18 -4
- data/resources/locales/en-IE/territories.yml +15 -15
- data/resources/locales/en-SG/calendars.yml +15 -5
- data/resources/locales/en-SG/currencies.yml +50 -10
- data/resources/locales/en-SG/languages.yml +99 -70
- data/resources/locales/en-SG/numbers.yml +74 -25
- data/resources/locales/en-SG/plural_rules.yml +10 -0
- data/resources/locales/en-SG/plurals.yml +18 -4
- data/resources/locales/en-SG/territories.yml +15 -15
- data/resources/locales/en-ZA/calendars.yml +12 -2
- data/resources/locales/en-ZA/currencies.yml +48 -9
- data/resources/locales/en-ZA/languages.yml +99 -70
- data/resources/locales/en-ZA/numbers.yml +74 -25
- data/resources/locales/en-ZA/plural_rules.yml +10 -0
- data/resources/locales/en-ZA/plurals.yml +18 -4
- data/resources/locales/en-ZA/territories.yml +15 -15
- data/resources/locales/en/calendars.yml +12 -2
- data/resources/locales/en/currencies.yml +49 -9
- data/resources/locales/en/languages.yml +99 -70
- data/resources/locales/en/numbers.yml +74 -25
- data/resources/locales/en/plural_rules.yml +10 -0
- data/resources/locales/en/plurals.yml +18 -4
- data/resources/locales/en/rbnf.yml +1 -26
- data/resources/locales/en/territories.yml +15 -15
- data/resources/locales/es-419/calendars.yml +101 -87
- data/resources/locales/es-419/currencies.yml +276 -276
- data/resources/locales/es-419/languages.yml +26 -90
- data/resources/locales/es-419/lists.yml +4 -4
- data/resources/locales/es-419/numbers.yml +74 -25
- data/resources/locales/es-419/plural_rules.yml +7 -0
- data/resources/locales/es-419/plurals.yml +13 -3
- data/resources/locales/es-419/rbnf.yml +1 -1192
- data/resources/locales/es-419/territories.yml +4 -4
- data/resources/locales/es-CO/calendars.yml +42 -28
- data/resources/locales/es-CO/currencies.yml +258 -258
- data/resources/locales/es-CO/languages.yml +22 -86
- data/resources/locales/es-CO/lists.yml +4 -4
- data/resources/locales/es-CO/numbers.yml +74 -25
- data/resources/locales/es-CO/plural_rules.yml +7 -0
- data/resources/locales/es-CO/plurals.yml +13 -3
- data/resources/locales/es-CO/rbnf.yml +1 -1
- data/resources/locales/es-CO/territories.yml +2 -2
- data/resources/locales/es-MX/calendars.yml +121 -107
- data/resources/locales/es-MX/currencies.yml +41 -136
- data/resources/locales/es-MX/languages.yml +27 -91
- data/resources/locales/es-MX/numbers.yml +76 -27
- data/resources/locales/es-MX/plural_rules.yml +7 -0
- data/resources/locales/es-MX/plurals.yml +13 -3
- data/resources/locales/es-MX/rbnf.yml +1 -1
- data/resources/locales/es-MX/territories.yml +7 -7
- data/resources/locales/es-US/calendars.yml +56 -48
- data/resources/locales/es-US/currencies.yml +259 -259
- data/resources/locales/es-US/languages.yml +22 -86
- data/resources/locales/es-US/lists.yml +4 -4
- data/resources/locales/es-US/numbers.yml +75 -26
- data/resources/locales/es-US/plural_rules.yml +7 -0
- data/resources/locales/es-US/plurals.yml +13 -3
- data/resources/locales/es-US/rbnf.yml +1 -1
- data/resources/locales/es-US/territories.yml +2 -2
- data/resources/locales/es/calendars.yml +38 -24
- data/resources/locales/es/currencies.yml +259 -259
- data/resources/locales/es/languages.yml +22 -86
- data/resources/locales/es/lists.yml +4 -4
- data/resources/locales/es/numbers.yml +75 -26
- data/resources/locales/es/plural_rules.yml +7 -0
- data/resources/locales/es/plurals.yml +13 -3
- data/resources/locales/es/rbnf.yml +8 -81
- data/resources/locales/es/territories.yml +2 -2
- data/resources/locales/eu/calendars.yml +72 -55
- data/resources/locales/eu/currencies.yml +135 -450
- data/resources/locales/eu/languages.yml +79 -414
- data/resources/locales/eu/lists.yml +4 -4
- data/resources/locales/eu/numbers.yml +74 -25
- data/resources/locales/eu/plural_rules.yml +7 -0
- data/resources/locales/eu/plurals.yml +13 -3
- data/resources/locales/eu/territories.yml +2 -2
- data/resources/locales/fa/calendars.yml +27 -12
- data/resources/locales/fa/currencies.yml +46 -454
- data/resources/locales/fa/languages.yml +71 -153
- data/resources/locales/fa/lists.yml +4 -4
- data/resources/locales/fa/numbers.yml +74 -25
- data/resources/locales/fa/plural_rules.yml +7 -0
- data/resources/locales/fa/plurals.yml +13 -3
- data/resources/locales/fa/territories.yml +4 -4
- data/resources/locales/fi/calendars.yml +20 -5
- data/resources/locales/fi/currencies.yml +287 -50
- data/resources/locales/fi/languages.yml +99 -70
- data/resources/locales/fi/numbers.yml +73 -24
- data/resources/locales/fi/plural_rules.yml +7 -0
- data/resources/locales/fi/plurals.yml +13 -4
- data/resources/locales/fi/territories.yml +1 -1
- data/resources/locales/fil/calendars.yml +29 -15
- data/resources/locales/fil/currencies.yml +144 -489
- data/resources/locales/fil/languages.yml +12 -339
- data/resources/locales/fil/lists.yml +7 -7
- data/resources/locales/fil/numbers.yml +74 -25
- data/resources/locales/fil/plural_rules.yml +8 -0
- data/resources/locales/fil/plurals.yml +17 -4
- data/resources/locales/fil/territories.yml +2 -2
- data/resources/locales/fr-BE/calendars.yml +68 -53
- data/resources/locales/fr-BE/currencies.yml +202 -82
- data/resources/locales/fr-BE/languages.yml +8 -71
- data/resources/locales/fr-BE/numbers.yml +74 -25
- data/resources/locales/fr-BE/plural_rules.yml +8 -0
- data/resources/locales/fr-BE/plurals.yml +15 -3
- data/resources/locales/fr-BE/territories.yml +7 -7
- data/resources/locales/fr-CA/calendars.yml +25 -10
- data/resources/locales/fr-CA/currencies.yml +250 -130
- data/resources/locales/fr-CA/languages.yml +11 -74
- data/resources/locales/fr-CA/numbers.yml +74 -25
- data/resources/locales/fr-CA/plural_rules.yml +8 -0
- data/resources/locales/fr-CA/plurals.yml +15 -3
- data/resources/locales/fr-CA/territories.yml +16 -16
- data/resources/locales/fr-CH/calendars.yml +68 -53
- data/resources/locales/fr-CH/currencies.yml +201 -82
- data/resources/locales/fr-CH/languages.yml +8 -71
- data/resources/locales/fr-CH/numbers.yml +74 -25
- data/resources/locales/fr-CH/plural_rules.yml +8 -0
- data/resources/locales/fr-CH/plurals.yml +15 -3
- data/resources/locales/fr-CH/territories.yml +7 -7
- data/resources/locales/fr/calendars.yml +68 -53
- data/resources/locales/fr/currencies.yml +202 -82
- data/resources/locales/fr/languages.yml +8 -71
- data/resources/locales/fr/numbers.yml +74 -25
- data/resources/locales/fr/plural_rules.yml +8 -0
- data/resources/locales/fr/plurals.yml +15 -3
- data/resources/locales/fr/territories.yml +7 -7
- data/resources/locales/ga/calendars.yml +136 -45
- data/resources/locales/ga/currencies.yml +1238 -587
- data/resources/locales/ga/languages.yml +176 -468
- data/resources/locales/ga/lists.yml +4 -4
- data/resources/locales/ga/numbers.yml +148 -24
- data/resources/locales/ga/plural_rules.yml +10 -0
- data/resources/locales/ga/plurals.yml +17 -5
- data/resources/locales/ga/territories.yml +56 -56
- data/resources/locales/gl/calendars.yml +26 -13
- data/resources/locales/gl/currencies.yml +378 -582
- data/resources/locales/gl/languages.yml +71 -392
- data/resources/locales/gl/lists.yml +8 -8
- data/resources/locales/gl/numbers.yml +74 -25
- data/resources/locales/gl/plural_rules.yml +7 -0
- data/resources/locales/gl/plurals.yml +13 -4
- data/resources/locales/gl/territories.yml +2 -2
- data/resources/locales/he/calendars.yml +53 -32
- data/resources/locales/he/currencies.yml +585 -487
- data/resources/locales/he/languages.yml +15 -78
- data/resources/locales/he/lists.yml +8 -8
- data/resources/locales/he/numbers.yml +121 -24
- data/resources/locales/he/plural_rules.yml +9 -0
- data/resources/locales/he/plurals.yml +16 -6
- data/resources/locales/he/rbnf.yml +0 -3
- data/resources/locales/he/territories.yml +4 -4
- data/resources/locales/hi/calendars.yml +54 -41
- data/resources/locales/hi/currencies.yml +155 -428
- data/resources/locales/hi/languages.yml +52 -141
- data/resources/locales/hi/lists.yml +4 -4
- data/resources/locales/hi/numbers.yml +74 -25
- data/resources/locales/hi/plural_rules.yml +11 -0
- data/resources/locales/hi/plurals.yml +19 -3
- data/resources/locales/hi/rbnf.yml +52 -1
- data/resources/locales/hi/territories.yml +8 -8
- data/resources/locales/hr/calendars.yml +30 -16
- data/resources/locales/hr/currencies.yml +306 -66
- data/resources/locales/hr/languages.yml +12 -76
- data/resources/locales/hr/numbers.yml +97 -24
- data/resources/locales/hr/plural_rules.yml +8 -0
- data/resources/locales/hr/plurals.yml +16 -8
- data/resources/locales/hr/territories.yml +1 -1
- data/resources/locales/hu/calendars.yml +25 -10
- data/resources/locales/hu/currencies.yml +139 -182
- data/resources/locales/hu/languages.yml +8 -72
- data/resources/locales/hu/lists.yml +4 -4
- data/resources/locales/hu/numbers.yml +73 -24
- data/resources/locales/hu/plural_rules.yml +8 -0
- data/resources/locales/hu/plurals.yml +15 -3
- data/resources/locales/hu/territories.yml +1 -1
- data/resources/locales/id/calendars.yml +22 -7
- data/resources/locales/id/currencies.yml +323 -192
- data/resources/locales/id/languages.yml +36 -71
- data/resources/locales/id/numbers.yml +50 -26
- data/resources/locales/id/plural_rules.yml +6 -0
- data/resources/locales/id/plurals.yml +11 -3
- data/resources/locales/id/rbnf.yml +4 -4
- data/resources/locales/id/territories.yml +2 -2
- data/resources/locales/is/calendars.yml +24 -9
- data/resources/locales/is/currencies.yml +145 -336
- data/resources/locales/is/languages.yml +57 -163
- data/resources/locales/is/numbers.yml +73 -24
- data/resources/locales/is/plural_rules.yml +7 -0
- data/resources/locales/is/plurals.yml +13 -5
- data/resources/locales/is/territories.yml +5 -5
- data/resources/locales/it-CH/calendars.yml +41 -26
- data/resources/locales/it-CH/currencies.yml +180 -274
- data/resources/locales/it-CH/languages.yml +106 -83
- data/resources/locales/it-CH/lists.yml +6 -6
- data/resources/locales/it-CH/numbers.yml +73 -24
- data/resources/locales/it-CH/plural_rules.yml +8 -0
- data/resources/locales/it-CH/plurals.yml +15 -4
- data/resources/locales/it-CH/territories.yml +9 -9
- data/resources/locales/it/calendars.yml +43 -28
- data/resources/locales/it/currencies.yml +181 -274
- data/resources/locales/it/languages.yml +106 -83
- data/resources/locales/it/lists.yml +6 -6
- data/resources/locales/it/numbers.yml +73 -24
- data/resources/locales/it/plural_rules.yml +8 -0
- data/resources/locales/it/plurals.yml +15 -4
- data/resources/locales/it/territories.yml +9 -9
- data/resources/locales/ja/calendars.yml +24 -9
- data/resources/locales/ja/currencies.yml +286 -48
- data/resources/locales/ja/languages.yml +106 -83
- data/resources/locales/ja/lists.yml +4 -4
- data/resources/locales/ja/numbers.yml +50 -26
- data/resources/locales/ja/plural_rules.yml +6 -0
- data/resources/locales/ja/plurals.yml +11 -3
- data/resources/locales/ja/territories.yml +2 -2
- data/resources/locales/ko/calendars.yml +63 -16
- data/resources/locales/ko/currencies.yml +286 -347
- data/resources/locales/ko/languages.yml +27 -76
- data/resources/locales/ko/numbers.yml +50 -26
- data/resources/locales/ko/plural_rules.yml +6 -0
- data/resources/locales/ko/plurals.yml +11 -3
- data/resources/locales/ko/territories.yml +4 -4
- data/resources/locales/lv/calendars.yml +34 -19
- data/resources/locales/lv/currencies.yml +155 -366
- data/resources/locales/lv/languages.yml +7 -71
- data/resources/locales/lv/numbers.yml +99 -26
- data/resources/locales/lv/plural_rules.yml +8 -0
- data/resources/locales/lv/plurals.yml +16 -9
- data/resources/locales/lv/territories.yml +2 -2
- data/resources/locales/ms/calendars.yml +28 -14
- data/resources/locales/ms/currencies.yml +185 -500
- data/resources/locales/ms/languages.yml +27 -297
- data/resources/locales/ms/lists.yml +6 -6
- data/resources/locales/ms/numbers.yml +50 -26
- data/resources/locales/ms/plural_rules.yml +7 -0
- data/resources/locales/ms/plurals.yml +13 -3
- data/resources/locales/ms/territories.yml +6 -6
- data/resources/locales/nb/calendars.yml +21 -6
- data/resources/locales/nb/currencies.yml +271 -44
- data/resources/locales/nb/languages.yml +14 -78
- data/resources/locales/nb/lists.yml +4 -4
- data/resources/locales/nb/numbers.yml +73 -24
- data/resources/locales/nb/plural_rules.yml +7 -0
- data/resources/locales/nb/plurals.yml +13 -3
- data/resources/locales/nb/territories.yml +6 -6
- data/resources/locales/nl/calendars.yml +63 -48
- data/resources/locales/nl/currencies.yml +294 -56
- data/resources/locales/nl/languages.yml +149 -121
- data/resources/locales/nl/numbers.yml +74 -25
- data/resources/locales/nl/plural_rules.yml +7 -0
- data/resources/locales/nl/plurals.yml +13 -4
- data/resources/locales/nl/territories.yml +9 -9
- data/resources/locales/pl/calendars.yml +23 -9
- data/resources/locales/pl/currencies.yml +147 -226
- data/resources/locales/pl/languages.yml +102 -73
- data/resources/locales/pl/numbers.yml +122 -25
- data/resources/locales/pl/plural_rules.yml +9 -0
- data/resources/locales/pl/plurals.yml +17 -9
- data/resources/locales/pl/rbnf.yml +17 -159
- data/resources/locales/pl/territories.yml +1 -1
- data/resources/locales/pt/calendars.yml +26 -12
- data/resources/locales/pt/currencies.yml +182 -91
- data/resources/locales/pt/languages.yml +72 -137
- data/resources/locales/pt/numbers.yml +74 -25
- data/resources/locales/pt/plural_rules.yml +7 -0
- data/resources/locales/pt/plurals.yml +13 -5
- data/resources/locales/pt/territories.yml +9 -9
- data/resources/locales/ro/calendars.yml +63 -49
- data/resources/locales/ro/currencies.yml +209 -291
- data/resources/locales/ro/languages.yml +12 -76
- data/resources/locales/ro/numbers.yml +98 -25
- data/resources/locales/ro/plural_rules.yml +9 -0
- data/resources/locales/ro/plurals.yml +17 -6
- data/resources/locales/ro/territories.yml +3 -3
- data/resources/locales/ru/calendars.yml +55 -41
- data/resources/locales/ru/currencies.yml +334 -256
- data/resources/locales/ru/languages.yml +8 -72
- data/resources/locales/ru/lists.yml +5 -5
- data/resources/locales/ru/numbers.yml +122 -24
- data/resources/locales/ru/plural_rules.yml +9 -0
- data/resources/locales/ru/plurals.yml +17 -7
- data/resources/locales/ru/rbnf.yml +15 -105
- data/resources/locales/ru/territories.yml +7 -7
- data/resources/locales/sk/calendars.yml +89 -51
- data/resources/locales/sk/currencies.yml +440 -415
- data/resources/locales/sk/languages.yml +50 -114
- data/resources/locales/sk/lists.yml +4 -4
- data/resources/locales/sk/numbers.yml +122 -25
- data/resources/locales/sk/plural_rules.yml +9 -0
- data/resources/locales/sk/plurals.yml +16 -6
- data/resources/locales/sk/territories.yml +18 -18
- data/resources/locales/sq/calendars.yml +72 -58
- data/resources/locales/sq/currencies.yml +86 -464
- data/resources/locales/sq/languages.yml +222 -579
- data/resources/locales/sq/lists.yml +4 -4
- data/resources/locales/sq/numbers.yml +73 -24
- data/resources/locales/sq/plural_rules.yml +9 -0
- data/resources/locales/sq/plurals.yml +16 -3
- data/resources/locales/sq/territories.yml +16 -17
- data/resources/locales/sr/calendars.yml +30 -16
- data/resources/locales/sr/currencies.yml +202 -116
- data/resources/locales/sr/languages.yml +200 -298
- data/resources/locales/sr/lists.yml +4 -4
- data/resources/locales/sr/numbers.yml +98 -25
- data/resources/locales/sr/plural_rules.yml +8 -0
- data/resources/locales/sr/plurals.yml +16 -8
- data/resources/locales/sr/territories.yml +20 -20
- data/resources/locales/sv/calendars.yml +46 -31
- data/resources/locales/sv/currencies.yml +213 -105
- data/resources/locales/sv/languages.yml +76 -73
- data/resources/locales/sv/numbers.yml +73 -25
- data/resources/locales/sv/plural_rules.yml +8 -0
- data/resources/locales/sv/plurals.yml +16 -4
- data/resources/locales/sv/rbnf.yml +1 -1
- data/resources/locales/sv/territories.yml +1 -1
- data/resources/locales/ta/calendars.yml +37 -23
- data/resources/locales/ta/currencies.yml +328 -643
- data/resources/locales/ta/languages.yml +94 -177
- data/resources/locales/ta/numbers.yml +74 -25
- data/resources/locales/ta/plural_rules.yml +7 -0
- data/resources/locales/ta/plurals.yml +13 -3
- data/resources/locales/ta/territories.yml +34 -34
- data/resources/locales/th/calendars.yml +33 -6
- data/resources/locales/th/currencies.yml +272 -187
- data/resources/locales/th/languages.yml +102 -76
- data/resources/locales/th/numbers.yml +50 -26
- data/resources/locales/th/plural_rules.yml +6 -0
- data/resources/locales/th/plurals.yml +11 -3
- data/resources/locales/th/territories.yml +2 -2
- data/resources/locales/tr/calendars.yml +25 -11
- data/resources/locales/tr/currencies.yml +365 -199
- data/resources/locales/tr/languages.yml +106 -77
- data/resources/locales/tr/numbers.yml +74 -25
- data/resources/locales/tr/plural_rules.yml +7 -0
- data/resources/locales/tr/plurals.yml +13 -3
- data/resources/locales/tr/territories.yml +5 -5
- data/resources/locales/uk/calendars.yml +24 -9
- data/resources/locales/uk/currencies.yml +139 -207
- data/resources/locales/uk/languages.yml +19 -94
- data/resources/locales/uk/lists.yml +6 -6
- data/resources/locales/uk/numbers.yml +121 -24
- data/resources/locales/uk/plural_rules.yml +10 -0
- data/resources/locales/uk/plurals.yml +19 -9
- data/resources/locales/uk/territories.yml +18 -18
- data/resources/locales/ur/calendars.yml +38 -16
- data/resources/locales/ur/currencies.yml +273 -577
- data/resources/locales/ur/languages.yml +76 -405
- data/resources/locales/ur/lists.yml +7 -7
- data/resources/locales/ur/numbers.yml +75 -26
- data/resources/locales/ur/plural_rules.yml +7 -0
- data/resources/locales/ur/plurals.yml +13 -4
- data/resources/locales/ur/territories.yml +1 -1
- data/resources/locales/vi/calendars.yml +29 -14
- data/resources/locales/vi/currencies.yml +273 -195
- data/resources/locales/vi/languages.yml +20 -94
- data/resources/locales/vi/lists.yml +2 -2
- data/resources/locales/vi/numbers.yml +49 -25
- data/resources/locales/vi/plural_rules.yml +7 -0
- data/resources/locales/vi/plurals.yml +13 -3
- data/resources/locales/vi/territories.yml +8 -8
- data/resources/locales/zh-Hant/calendars.yml +28 -13
- data/resources/locales/zh-Hant/currencies.yml +368 -134
- data/resources/locales/zh-Hant/languages.yml +119 -90
- data/resources/locales/zh-Hant/lists.yml +4 -4
- data/resources/locales/zh-Hant/numbers.yml +50 -26
- data/resources/locales/zh-Hant/plural_rules.yml +6 -0
- data/resources/locales/zh-Hant/plurals.yml +11 -3
- data/resources/locales/zh-Hant/territories.yml +9 -9
- data/resources/locales/zh/calendars.yml +20 -5
- data/resources/locales/zh/currencies.yml +372 -189
- data/resources/locales/zh/languages.yml +7 -71
- data/resources/locales/zh/lists.yml +4 -4
- data/resources/locales/zh/numbers.yml +50 -26
- data/resources/locales/zh/plural_rules.yml +6 -0
- data/resources/locales/zh/plurals.yml +11 -3
- data/resources/locales/zh/rbnf.yml +46 -0
- data/resources/shared/currency_digits_and_rounding.yml +8 -2
- data/resources/shared/numbering_systems.yml +3 -0
- data/resources/shared/postal_codes.yml +320 -1275
- data/resources/shared/rbnf_root.yml +65 -16
- data/resources/shared/territories_containment.yml +1 -0
- data/resources/uli/segments/de.yml +102 -0
- data/resources/uli/segments/es.yml +33 -0
- data/resources/uli/segments/fr.yml +21 -0
- data/resources/uli/segments/it.yml +11 -0
- data/spec/data_readers/number_data_reader_spec.rb +25 -0
- data/spec/formatters/list_formatter_spec.rb +2 -2
- data/spec/formatters/numbers/abbreviated/abbreviated_number_formatter_spec.rb +11 -17
- data/spec/formatters/numbers/abbreviated/long_decimal_formatter_spec.rb +80 -31
- data/spec/formatters/numbers/abbreviated/short_decimal_formatter_spec.rb +40 -9
- data/spec/formatters/numbers/currency_formatter_spec.rb +1 -1
- data/spec/formatters/numbers/rbnf/allowed_failures.yml +47 -35
- data/spec/formatters/numbers/rbnf/locales/bn/rbnf_test.yml +1634 -1283
- data/spec/formatters/numbers/rbnf/locales/cy/rbnf_test.yml +42 -42
- data/spec/formatters/numbers/rbnf/locales/de-CH/rbnf_test.yml +702 -0
- data/spec/formatters/numbers/rbnf/locales/de/rbnf_test.yml +702 -0
- data/spec/formatters/numbers/rbnf/locales/es-419/rbnf_test.yml +14 -14
- data/spec/formatters/numbers/rbnf/locales/es-CO/rbnf_test.yml +14 -14
- data/spec/formatters/numbers/rbnf/locales/es-MX/rbnf_test.yml +14 -14
- data/spec/formatters/numbers/rbnf/locales/es-US/rbnf_test.yml +14 -14
- data/spec/formatters/numbers/rbnf/locales/es/rbnf_test.yml +54 -54
- data/spec/formatters/numbers/rbnf/locales/eu/rbnf_test.yml +1634 -1283
- data/spec/formatters/numbers/rbnf/locales/fr-CH/rbnf_test.yml +32 -32
- data/spec/formatters/numbers/rbnf/locales/gl/rbnf_test.yml +1634 -1283
- data/spec/formatters/numbers/rbnf/locales/he/rbnf_test.yml +105 -105
- data/spec/formatters/numbers/rbnf/locales/hi/rbnf_test.yml +350 -116
- data/spec/formatters/numbers/rbnf/locales/sv/rbnf_test.yml +24 -24
- data/spec/formatters/numbers/rbnf/locales/ur/rbnf_test.yml +1634 -1283
- data/spec/formatters/numbers/rbnf/locales/zh/rbnf_test.yml +117 -0
- data/spec/formatters/plurals/rules_spec.rb +37 -14
- data/spec/localized/localized_number_spec.rb +2 -1
- data/spec/parsers/number_parser_spec.rb +5 -5
- data/spec/shared/calendar_spec.rb +3 -3
- data/spec/shared/postal_codes_spec.rb +16 -0
- data/spec/shared/territories_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -1
- data/twitter_cldr.gemspec +1 -0
- metadata +364 -285
- data/resources/custom/locales/hu/plurals.yml +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: accacbf47c61c3008a7cdae91acde6d4bb848bc9
|
4
|
+
data.tar.gz: 112cdf6e94bc614b5677289ee345b4ea38bd55e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f923179204c1627ebe184f5fe38d2249e0016b1c20a524c0c0b7e06c3382f19240b054866daf0019edf9215e6034c1bc65d942e4914c8ed4332894883fdd6402
|
7
|
+
data.tar.gz: 48dd5f10034e32e5900abec0f02a1ff11e0e98bb14dd6921f355b1e171f2fa03bc8c1f68bfb885244abdd9c0b8b1f3fa16cefc62f582c77f661f9db8fbd91050
|
data/Gemfile
CHANGED
@@ -20,13 +20,14 @@ group :development, :test do
|
|
20
20
|
gem 'oniguruma'
|
21
21
|
end
|
22
22
|
|
23
|
-
gem 'regexp_parser', '~> 0.1.
|
23
|
+
gem 'regexp_parser', '~> 0.1.6'
|
24
24
|
end
|
25
25
|
|
26
26
|
group :development do
|
27
27
|
gem 'nokogiri', "~> 1.5.9"
|
28
28
|
|
29
|
-
gem 'ruby-cldr', :github => '
|
29
|
+
gem 'ruby-cldr', :github => 'kl-7/ruby-cldr', :branch => 'kl_nubmber_patttern_pluralization'
|
30
|
+
gem 'cldr-plurals', '~> 1.0.0'
|
30
31
|
end
|
31
32
|
|
32
33
|
group :test do
|
data/History.txt
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
== 3.1.0
|
2
|
+
|
3
|
+
* Updated resources from CLDR v26 (except the collation data).
|
4
|
+
* Added support for ordinal plurals.
|
5
|
+
* Added PostalCodes#find_all method.
|
6
|
+
* Added negative numbers abbreviation.
|
7
|
+
* Fixed pluralization for abbreviated numbers.
|
8
|
+
* Fixed pluralization rules by not merging 'en' rules into every locale.
|
9
|
+
|
1
10
|
== 3.0.10
|
2
11
|
|
3
12
|
* Adding Date back in as a localizable object.
|
data/README.md
CHANGED
@@ -456,6 +456,14 @@ postal_code = TwitterCldr::Shared::PostalCodes.for_territory(:ca)
|
|
456
456
|
postal_code.valid?("V3H 1Z7") # true
|
457
457
|
```
|
458
458
|
|
459
|
+
Match all valid postal codes in a string with the `#find_all` method:
|
460
|
+
|
461
|
+
```ruby
|
462
|
+
# United States
|
463
|
+
postal_code = TwitterCldr::Shared::PostalCodes.for_territory(:us)
|
464
|
+
postal_code.find_all("12345 23456") # ["12345", "23456"]
|
465
|
+
```
|
466
|
+
|
459
467
|
Get a list of supported territories by using the `#territories` method:
|
460
468
|
|
461
469
|
```ruby
|
data/Rakefile
CHANGED
@@ -96,7 +96,7 @@ end
|
|
96
96
|
# TODO: 'add_locale' task that creates a new directory and runs all necessary 'update' tasks (+ suggests to run those that depend on JRuby)
|
97
97
|
|
98
98
|
namespace :update do
|
99
|
-
ICU_JAR = './vendor/icu4j
|
99
|
+
ICU_JAR = './vendor/icu4j.jar'
|
100
100
|
|
101
101
|
desc 'Import locales resources'
|
102
102
|
task :locales_resources, :cldr_path do |_, args|
|
data/lib/twitter_cldr.rb
CHANGED
@@ -33,7 +33,7 @@ module TwitterCldr
|
|
33
33
|
extend SingleForwardable
|
34
34
|
|
35
35
|
# version of CLDR that was used for generating YAML files in the resources/ directory
|
36
|
-
CLDR_VERSION = '
|
36
|
+
CLDR_VERSION = '26.0' # release date: 2014-09-18
|
37
37
|
|
38
38
|
DEFAULT_LOCALE = :en
|
39
39
|
DEFAULT_CALENDAR_TYPE = :gregorian
|
@@ -32,6 +32,8 @@ module TwitterCldr
|
|
32
32
|
DEFAULT_FORMAT = :default
|
33
33
|
DEFAULT_SIGN = :positive
|
34
34
|
|
35
|
+
REDIRECT_REGEX = /\Anumbers\.formats\.\w+\.patterns\.\w+\z/
|
36
|
+
|
35
37
|
attr_reader :type, :format
|
36
38
|
|
37
39
|
def self.types
|
@@ -49,7 +51,20 @@ module TwitterCldr
|
|
49
51
|
@format = options[:format] || DEFAULT_FORMAT
|
50
52
|
end
|
51
53
|
|
52
|
-
def
|
54
|
+
def format_number(number, options = [])
|
55
|
+
precision = options[:precision] || 0
|
56
|
+
pattern_for_number = pattern(number, precision == 0)
|
57
|
+
|
58
|
+
if pattern_for_number == 0
|
59
|
+
# there's no specific formatting for the number in the current locale
|
60
|
+
number.to_s
|
61
|
+
else
|
62
|
+
tokens = tokenizer.tokenize(pattern_for_number)
|
63
|
+
formatter.format(tokens, number, options)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def pattern(number = nil, decimal = true)
|
53
68
|
sign = number < 0 ? :negative : :positive
|
54
69
|
path = BASE_PATH + if valid_type_for?(number, type)
|
55
70
|
TYPE_PATHS[type]
|
@@ -57,14 +72,14 @@ module TwitterCldr
|
|
57
72
|
TYPE_PATHS[:default]
|
58
73
|
end
|
59
74
|
|
60
|
-
pattern =
|
75
|
+
pattern = get_pattern_data(path)
|
61
76
|
|
62
77
|
if pattern[format]
|
63
78
|
pattern = pattern[format]
|
64
79
|
end
|
65
80
|
|
66
81
|
if number
|
67
|
-
pattern = pattern_for_number(pattern, number)
|
82
|
+
pattern = pattern_for_number(pattern, number, decimal)
|
68
83
|
end
|
69
84
|
|
70
85
|
if pattern.is_a?(String)
|
@@ -96,6 +111,16 @@ module TwitterCldr
|
|
96
111
|
|
97
112
|
private
|
98
113
|
|
114
|
+
def get_pattern_data(path)
|
115
|
+
data = traverse(path)
|
116
|
+
|
117
|
+
if data.is_a?(Symbol) && data.to_s =~ REDIRECT_REGEX
|
118
|
+
get_pattern_data(data.to_s.split('.').map(&:to_sym))
|
119
|
+
else
|
120
|
+
data
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
99
124
|
def abbreviated?(type)
|
100
125
|
ABBREVIATED_TYPES.include?(type)
|
101
126
|
end
|
@@ -109,17 +134,43 @@ module TwitterCldr
|
|
109
134
|
end
|
110
135
|
|
111
136
|
def get_key_for(number)
|
112
|
-
"1#{"0" * (number.to_i.to_s.size - 1)}".to_i
|
137
|
+
"1#{"0" * (number.to_i.abs.to_s.size - 1)}".to_i
|
113
138
|
end
|
114
139
|
|
115
|
-
def pattern_for_number(pattern, number)
|
140
|
+
def pattern_for_number(pattern, number, decimal)
|
116
141
|
if pattern.is_a?(Hash)
|
117
|
-
pattern[get_key_for(number)]
|
142
|
+
range_pattern = pattern[get_key_for(number)]
|
143
|
+
|
144
|
+
if range_pattern
|
145
|
+
pattern_sample = range_pattern.values.first
|
146
|
+
|
147
|
+
if pattern_sample != 0
|
148
|
+
rule = pluralization_rule(number, pattern_sample, decimal)
|
149
|
+
# fall back to :other and raise an exception if it's missing as well
|
150
|
+
range_pattern.fetch(rule, range_pattern.fetch(:other))
|
151
|
+
else
|
152
|
+
0
|
153
|
+
end
|
154
|
+
else
|
155
|
+
pattern
|
156
|
+
end
|
118
157
|
else
|
119
158
|
pattern
|
120
159
|
end
|
121
160
|
end
|
122
161
|
|
162
|
+
def truncate_number(number, pattern)
|
163
|
+
formatter.truncate_number(number, tokenizer.tokenize(pattern)[1].value.size)
|
164
|
+
end
|
165
|
+
|
166
|
+
def pluralization_rule(number, pattern, decimal)
|
167
|
+
truncated_number = truncate_number(number, pattern)
|
168
|
+
# decimal and fractional numbers might have different pluralization,
|
169
|
+
# so it's important to convert to integer if we want a decimal result
|
170
|
+
truncated_number = truncated_number.to_i if decimal
|
171
|
+
TwitterCldr::Formatters::Plurals::Rules.rule_for(truncated_number, locale)
|
172
|
+
end
|
173
|
+
|
123
174
|
def pattern_for_sign(pattern, sign)
|
124
175
|
if pattern.include?(";")
|
125
176
|
positive, negative = pattern.split(";")
|
@@ -127,7 +178,7 @@ module TwitterCldr
|
|
127
178
|
else
|
128
179
|
case sign
|
129
180
|
when :negative
|
130
|
-
"#{symbols[:
|
181
|
+
"#{symbols[:minus_sign] || '-'}#{pattern}"
|
131
182
|
else
|
132
183
|
pattern
|
133
184
|
end
|
@@ -142,7 +193,8 @@ module TwitterCldr
|
|
142
193
|
end
|
143
194
|
|
144
195
|
def self.within_abbreviation_range?(number)
|
145
|
-
|
196
|
+
abs_value = number.abs
|
197
|
+
NUMBER_MIN <= abs_value && abs_value < NUMBER_MAX
|
146
198
|
end
|
147
199
|
end
|
148
200
|
end
|
@@ -7,18 +7,10 @@ module TwitterCldr
|
|
7
7
|
module Formatters
|
8
8
|
class AbbreviatedNumberFormatter < NumberFormatter
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
protected
|
13
|
-
|
14
|
-
def truncate_number(number, integer_format)
|
10
|
+
def truncate_number(number, decimal_digits)
|
15
11
|
if TwitterCldr::DataReaders::NumberDataReader.within_abbreviation_range?(number)
|
16
|
-
|
17
|
-
|
18
|
-
number / (10.0 ** factor)
|
19
|
-
else
|
20
|
-
raise ArgumentError.new("unexpected format string #{integer_format.inspect}")
|
21
|
-
end
|
12
|
+
factor = [0, number.to_i.abs.to_s.length - decimal_digits].max
|
13
|
+
number / (10.0 ** factor)
|
22
14
|
else
|
23
15
|
number
|
24
16
|
end
|
@@ -7,13 +7,6 @@ module TwitterCldr
|
|
7
7
|
module Formatters
|
8
8
|
class NumberFormatter < Formatter
|
9
9
|
|
10
|
-
DEFAULT_SYMBOLS = {
|
11
|
-
:group => ',',
|
12
|
-
:decimal => '.',
|
13
|
-
:plus_sign => '+',
|
14
|
-
:minus_sign => '-'
|
15
|
-
}
|
16
|
-
|
17
10
|
attr_reader :data_reader
|
18
11
|
|
19
12
|
def initialize(data_reader)
|
@@ -25,7 +18,7 @@ module TwitterCldr
|
|
25
18
|
options[:type] ||= :decimal
|
26
19
|
|
27
20
|
prefix, suffix, integer_format, fraction_format = *partition_tokens(tokens)
|
28
|
-
number = truncate_number(number, integer_format)
|
21
|
+
number = truncate_number(number, integer_format.format.length)
|
29
22
|
|
30
23
|
int, fraction = parse_number(number, options)
|
31
24
|
result = integer_format.apply(int, options)
|
@@ -36,6 +29,10 @@ module TwitterCldr
|
|
36
29
|
)
|
37
30
|
end
|
38
31
|
|
32
|
+
def truncate_number(number, decimal_digits)
|
33
|
+
number # noop for base class
|
34
|
+
end
|
35
|
+
|
39
36
|
protected
|
40
37
|
|
41
38
|
# data readers should encapsulate formatting options, and when they do, this "type"
|
@@ -46,10 +43,6 @@ module TwitterCldr
|
|
46
43
|
)
|
47
44
|
end
|
48
45
|
|
49
|
-
def truncate_number(number, integer_format)
|
50
|
-
number # noop for base class
|
51
|
-
end
|
52
|
-
|
53
46
|
def partition_tokens(tokens)
|
54
47
|
[
|
55
48
|
token_val_from(tokens[0]),
|
@@ -18,6 +18,7 @@ module TwitterCldr
|
|
18
18
|
autoload :RuleGroup, "twitter_cldr/formatters/numbers/rbnf/rule_group"
|
19
19
|
autoload :RuleParser, "twitter_cldr/formatters/numbers/rbnf/rule_parser"
|
20
20
|
autoload :Substitution, "twitter_cldr/formatters/numbers/rbnf/substitution"
|
21
|
+
autoload :Plural, "twitter_cldr/formatters/numbers/rbnf/plural"
|
21
22
|
|
22
23
|
class PrivateRuleSetError < StandardError; end
|
23
24
|
|
@@ -100,7 +101,7 @@ module TwitterCldr
|
|
100
101
|
def rule_set_from_resource(rule_set_data)
|
101
102
|
RuleSet.new(
|
102
103
|
rule_set_data[:rules].map do |rule|
|
103
|
-
Rule.new(rule[:value], rule[:rule], rule[:radix])
|
104
|
+
Rule.new(rule[:value], rule[:rule], rule[:radix], locale)
|
104
105
|
end,
|
105
106
|
rule_set_data[:type],
|
106
107
|
rule_set_data[:access] || "public"
|
@@ -16,7 +16,6 @@ module TwitterCldr
|
|
16
16
|
|
17
17
|
def format(number, rule_set, rule_group, locale)
|
18
18
|
rule = rule_set.rule_for(number)
|
19
|
-
# puts "#{number}, #{rule.base_value}: '" + rule.rule_text + "'"
|
20
19
|
formatter = formatter_for(rule, rule_set, rule_group, locale)
|
21
20
|
result = formatter.format(number, rule)
|
22
21
|
keep_soft_hyphens ? result : remove_soft_hyphens(result)
|
@@ -120,6 +119,10 @@ module TwitterCldr
|
|
120
119
|
""
|
121
120
|
end
|
122
121
|
|
122
|
+
def plural(number, rule, token)
|
123
|
+
token.render(number / rule.divisor)
|
124
|
+
end
|
125
|
+
|
123
126
|
protected
|
124
127
|
|
125
128
|
def invalid_token_error(token)
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
# Copyright 2012 Twitter, Inc
|
4
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
5
|
+
|
6
|
+
module TwitterCldr
|
7
|
+
module Formatters
|
8
|
+
module Rbnf
|
9
|
+
|
10
|
+
class Plural
|
11
|
+
def self.from_string(locale, str)
|
12
|
+
# $(cardinal,one{ tysiąc}few{ tysiące}other{ tysięcy})$
|
13
|
+
plural_type, cases = str.gsub(/\$\((.*)\)\$/, '\1').split(',')
|
14
|
+
|
15
|
+
# one{ tysiąc}few{ tysiące}other{ tysięcy}
|
16
|
+
cases = cases.scan(/([\w]+)\{([^}]+)\}/).inject({}) do |ret, case_arr|
|
17
|
+
ret[case_arr.first.to_sym] = case_arr.last
|
18
|
+
ret
|
19
|
+
end
|
20
|
+
|
21
|
+
new(locale, plural_type.to_sym, cases)
|
22
|
+
end
|
23
|
+
|
24
|
+
attr_reader :locale, :plural_type, :cases
|
25
|
+
|
26
|
+
# plural_type = cardinal, etc
|
27
|
+
# cases = hash of form one: "foo", two: "bar"
|
28
|
+
def initialize(locale, plural_type, cases)
|
29
|
+
@locale = locale
|
30
|
+
@plural_type = plural_type
|
31
|
+
@cases = cases
|
32
|
+
end
|
33
|
+
|
34
|
+
def render(number)
|
35
|
+
rule_name = TwitterCldr::Formatters::Plurals::Rules.rule_for(
|
36
|
+
number, locale, plural_type
|
37
|
+
)
|
38
|
+
|
39
|
+
cases[rule_name] || cases[:other]
|
40
|
+
end
|
41
|
+
|
42
|
+
def type
|
43
|
+
:plural
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -14,12 +14,13 @@ module TwitterCldr
|
|
14
14
|
PROPER_FRACTION = "0.x"
|
15
15
|
NEGATIVE = "-x"
|
16
16
|
|
17
|
-
attr_reader :base_value, :rule_text, :radix
|
17
|
+
attr_reader :base_value, :rule_text, :radix, :locale
|
18
18
|
|
19
|
-
def initialize(base_value, rule_text, radix)
|
19
|
+
def initialize(base_value, rule_text, radix, locale)
|
20
20
|
@base_value = base_value
|
21
21
|
@rule_text = rule_text
|
22
22
|
@radix = radix
|
23
|
+
@locale = locale
|
23
24
|
end
|
24
25
|
|
25
26
|
def divisor
|
@@ -76,7 +77,7 @@ module TwitterCldr
|
|
76
77
|
private
|
77
78
|
|
78
79
|
def inline_substitutions(tokens)
|
79
|
-
parser.parse(tokens)
|
80
|
+
parser.parse(tokens, :locale => locale)
|
80
81
|
end
|
81
82
|
|
82
83
|
def parser
|
@@ -12,6 +12,7 @@ module TwitterCldr
|
|
12
12
|
private
|
13
13
|
|
14
14
|
def do_parse(options)
|
15
|
+
@locale = options.fetch(:locale, TwitterCldr.locale)
|
15
16
|
switch([])
|
16
17
|
end
|
17
18
|
|
@@ -48,6 +49,16 @@ module TwitterCldr
|
|
48
49
|
switch(list)
|
49
50
|
end
|
50
51
|
|
52
|
+
def plural(list)
|
53
|
+
sub = Plural.from_string(
|
54
|
+
@locale, current_token.value
|
55
|
+
)
|
56
|
+
|
57
|
+
list << sub
|
58
|
+
next_token(:plural)
|
59
|
+
switch(list)
|
60
|
+
end
|
61
|
+
|
51
62
|
def plaintext(list)
|
52
63
|
add_and_advance(list)
|
53
64
|
end
|
@@ -83,4 +94,4 @@ module TwitterCldr
|
|
83
94
|
end
|
84
95
|
end
|
85
96
|
end
|
86
|
-
end
|
97
|
+
end
|
@@ -3,6 +3,8 @@
|
|
3
3
|
# Copyright 2012 Twitter, Inc
|
4
4
|
# http://www.apache.org/licenses/LICENSE-2.0
|
5
5
|
|
6
|
+
require 'cldr-plurals/ruby_runtime'
|
7
|
+
|
6
8
|
module TwitterCldr
|
7
9
|
module Formatters
|
8
10
|
module Plurals
|
@@ -10,18 +12,18 @@ module TwitterCldr
|
|
10
12
|
|
11
13
|
class << self
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
+
DEFAULT_TYPE = :cardinal
|
16
|
+
|
17
|
+
def all(type = DEFAULT_TYPE)
|
18
|
+
all_for(TwitterCldr.locale, type)
|
15
19
|
end
|
16
20
|
|
17
|
-
def all_for(locale)
|
18
|
-
|
19
|
-
rescue
|
20
|
-
nil
|
21
|
+
def all_for(locale, type = DEFAULT_TYPE)
|
22
|
+
names(locale, type)
|
21
23
|
end
|
22
24
|
|
23
|
-
def rule_for(number, locale = TwitterCldr.locale)
|
24
|
-
|
25
|
+
def rule_for(number, locale = TwitterCldr.locale, type = DEFAULT_TYPE)
|
26
|
+
rule(locale, type).call(number.to_s, CldrPlurals::RubyRuntime)
|
25
27
|
rescue
|
26
28
|
:other
|
27
29
|
end
|
@@ -31,7 +33,21 @@ module TwitterCldr
|
|
31
33
|
def get_resource(locale)
|
32
34
|
locale = TwitterCldr.convert_locale(locale)
|
33
35
|
cache_key = TwitterCldr::Utils.compute_cache_key(locale)
|
34
|
-
locale_cache[cache_key] ||=
|
36
|
+
locale_cache[cache_key] ||= begin
|
37
|
+
rsrc = TwitterCldr.get_locale_resource(locale, :plurals)[locale]
|
38
|
+
rsrc.inject({}) do |ret, (rule_type, rule_data)|
|
39
|
+
ret[rule_type] = rule_data.merge(:rule => eval(rule_data[:rule]))
|
40
|
+
ret
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def rule(locale, type)
|
46
|
+
get_resource(locale)[type][:rule]
|
47
|
+
end
|
48
|
+
|
49
|
+
def names(locale, type)
|
50
|
+
get_resource(locale)[type][:names]
|
35
51
|
end
|
36
52
|
|
37
53
|
def locale_cache
|
@@ -43,4 +59,4 @@ module TwitterCldr
|
|
43
59
|
end
|
44
60
|
end
|
45
61
|
end
|
46
|
-
end
|
62
|
+
end
|