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.
Files changed (569) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -2
  3. data/History.txt +9 -0
  4. data/README.md +8 -0
  5. data/Rakefile +1 -1
  6. data/lib/twitter_cldr.rb +1 -1
  7. data/lib/twitter_cldr/data_readers/number_data_reader.rb +60 -8
  8. data/lib/twitter_cldr/formatters/numbers/abbreviated/abbreviated_number_formatter.rb +3 -11
  9. data/lib/twitter_cldr/formatters/numbers/number_formatter.rb +5 -12
  10. data/lib/twitter_cldr/formatters/numbers/rbnf.rb +2 -1
  11. data/lib/twitter_cldr/formatters/numbers/rbnf/formatters.rb +4 -1
  12. data/lib/twitter_cldr/formatters/numbers/rbnf/plural.rb +49 -0
  13. data/lib/twitter_cldr/formatters/numbers/rbnf/rule.rb +4 -3
  14. data/lib/twitter_cldr/formatters/numbers/rbnf/rule_parser.rb +12 -1
  15. data/lib/twitter_cldr/formatters/numbers/rbnf/substitution.rb +1 -1
  16. data/lib/twitter_cldr/formatters/plurals/rules.rb +26 -10
  17. data/lib/twitter_cldr/localized/localized_number.rb +2 -15
  18. data/lib/twitter_cldr/resources/download.rb +3 -3
  19. data/lib/twitter_cldr/resources/locales_resources_importer.rb +24 -16
  20. data/lib/twitter_cldr/resources/uli/segment_exceptions_importer.rb +1 -1
  21. data/lib/twitter_cldr/shared/postal_codes.rb +30 -2
  22. data/lib/twitter_cldr/tokenizers/numbers/rbnf_tokenizer.rb +2 -1
  23. data/lib/twitter_cldr/version.rb +1 -1
  24. data/resources/locales/af/calendars.yml +44 -29
  25. data/resources/locales/af/currencies.yml +300 -603
  26. data/resources/locales/af/languages.yml +22 -359
  27. data/resources/locales/af/lists.yml +8 -8
  28. data/resources/locales/af/numbers.yml +74 -25
  29. data/resources/locales/af/plural_rules.yml +7 -0
  30. data/resources/locales/af/plurals.yml +13 -3
  31. data/resources/locales/af/territories.yml +7 -7
  32. data/resources/locales/ar/calendars.yml +25 -11
  33. data/resources/locales/ar/currencies.yml +115 -229
  34. data/resources/locales/ar/languages.yml +39 -124
  35. data/resources/locales/ar/lists.yml +12 -12
  36. data/resources/locales/ar/numbers.yml +170 -25
  37. data/resources/locales/ar/plural_rules.yml +11 -0
  38. data/resources/locales/ar/plurals.yml +18 -6
  39. data/resources/locales/be/calendars.yml +10 -20
  40. data/resources/locales/be/currencies.yml +40 -778
  41. data/resources/locales/be/languages.yml +2 -447
  42. data/resources/locales/be/lists.yml +3 -15
  43. data/resources/locales/be/numbers.yml +26 -26
  44. data/resources/locales/be/plural_rules.yml +9 -0
  45. data/resources/locales/be/plurals.yml +17 -7
  46. data/resources/locales/be/rbnf.yml +15 -105
  47. data/resources/locales/be/territories.yml +5 -16
  48. data/resources/locales/bg/calendars.yml +61 -40
  49. data/resources/locales/bg/currencies.yml +147 -176
  50. data/resources/locales/bg/languages.yml +56 -149
  51. data/resources/locales/bg/lists.yml +5 -5
  52. data/resources/locales/bg/numbers.yml +73 -24
  53. data/resources/locales/bg/plural_rules.yml +7 -0
  54. data/resources/locales/bg/plurals.yml +13 -3
  55. data/resources/locales/bg/territories.yml +10 -10
  56. data/resources/locales/bn/calendars.yml +43 -29
  57. data/resources/locales/bn/currencies.yml +156 -253
  58. data/resources/locales/bn/languages.yml +61 -150
  59. data/resources/locales/bn/lists.yml +4 -4
  60. data/resources/locales/bn/numbers.yml +74 -25
  61. data/resources/locales/bn/plural_rules.yml +11 -0
  62. data/resources/locales/bn/plurals.yml +19 -3
  63. data/resources/locales/bn/territories.yml +35 -35
  64. data/resources/locales/ca/calendars.yml +38 -23
  65. data/resources/locales/ca/currencies.yml +285 -63
  66. data/resources/locales/ca/languages.yml +12 -76
  67. data/resources/locales/ca/lists.yml +4 -4
  68. data/resources/locales/ca/numbers.yml +74 -25
  69. data/resources/locales/ca/plural_rules.yml +10 -0
  70. data/resources/locales/ca/plurals.yml +17 -4
  71. data/resources/locales/ca/territories.yml +20 -20
  72. data/resources/locales/cs/calendars.yml +33 -18
  73. data/resources/locales/cs/currencies.yml +397 -118
  74. data/resources/locales/cs/languages.yml +109 -90
  75. data/resources/locales/cs/numbers.yml +121 -24
  76. data/resources/locales/cs/plural_rules.yml +9 -0
  77. data/resources/locales/cs/plurals.yml +16 -6
  78. data/resources/locales/cs/territories.yml +2 -2
  79. data/resources/locales/cy/calendars.yml +4 -5
  80. data/resources/locales/cy/currencies.yml +56 -424
  81. data/resources/locales/cy/languages.yml +210 -379
  82. data/resources/locales/cy/lists.yml +1 -5
  83. data/resources/locales/cy/numbers.yml +170 -25
  84. data/resources/locales/cy/plural_rules.yml +16 -0
  85. data/resources/locales/cy/plurals.yml +26 -4
  86. data/resources/locales/cy/rbnf.yml +8 -8
  87. data/resources/locales/da/calendars.yml +28 -13
  88. data/resources/locales/da/currencies.yml +135 -136
  89. data/resources/locales/da/languages.yml +10 -74
  90. data/resources/locales/da/numbers.yml +73 -24
  91. data/resources/locales/da/plural_rules.yml +7 -0
  92. data/resources/locales/da/plurals.yml +13 -4
  93. data/resources/locales/da/territories.yml +2 -2
  94. data/resources/locales/de-CH/calendars.yml +29 -15
  95. data/resources/locales/de-CH/currencies.yml +327 -101
  96. data/resources/locales/de-CH/languages.yml +112 -83
  97. data/resources/locales/de-CH/numbers.yml +73 -24
  98. data/resources/locales/de-CH/plural_rules.yml +7 -0
  99. data/resources/locales/de-CH/plurals.yml +13 -4
  100. data/resources/locales/de-CH/territories.yml +3 -3
  101. data/resources/locales/de/calendars.yml +29 -15
  102. data/resources/locales/de/currencies.yml +328 -101
  103. data/resources/locales/de/languages.yml +112 -83
  104. data/resources/locales/de/numbers.yml +73 -24
  105. data/resources/locales/de/plural_rules.yml +7 -0
  106. data/resources/locales/de/plurals.yml +13 -4
  107. data/resources/locales/de/rbnf.yml +189 -0
  108. data/resources/locales/de/territories.yml +3 -3
  109. data/resources/locales/el/calendars.yml +30 -16
  110. data/resources/locales/el/currencies.yml +144 -91
  111. data/resources/locales/el/languages.yml +8 -72
  112. data/resources/locales/el/numbers.yml +73 -24
  113. data/resources/locales/el/plural_rules.yml +7 -0
  114. data/resources/locales/el/plurals.yml +13 -3
  115. data/resources/locales/el/territories.yml +1 -1
  116. data/resources/locales/en-150/calendars.yml +15 -5
  117. data/resources/locales/en-150/currencies.yml +49 -9
  118. data/resources/locales/en-150/languages.yml +99 -70
  119. data/resources/locales/en-150/numbers.yml +73 -24
  120. data/resources/locales/en-150/plural_rules.yml +10 -0
  121. data/resources/locales/en-150/plurals.yml +18 -4
  122. data/resources/locales/en-150/territories.yml +15 -15
  123. data/resources/locales/en-AU/calendars.yml +21 -11
  124. data/resources/locales/en-AU/currencies.yml +69 -29
  125. data/resources/locales/en-AU/languages.yml +101 -72
  126. data/resources/locales/en-AU/lists.yml +1 -1
  127. data/resources/locales/en-AU/numbers.yml +73 -24
  128. data/resources/locales/en-AU/plural_rules.yml +10 -0
  129. data/resources/locales/en-AU/plurals.yml +18 -4
  130. data/resources/locales/en-AU/territories.yml +19 -19
  131. data/resources/locales/en-CA/calendars.yml +18 -8
  132. data/resources/locales/en-CA/currencies.yml +49 -9
  133. data/resources/locales/en-CA/languages.yml +99 -70
  134. data/resources/locales/en-CA/numbers.yml +74 -25
  135. data/resources/locales/en-CA/plural_rules.yml +10 -0
  136. data/resources/locales/en-CA/plurals.yml +18 -4
  137. data/resources/locales/en-CA/territories.yml +15 -15
  138. data/resources/locales/en-GB/calendars.yml +21 -8
  139. data/resources/locales/en-GB/currencies.yml +242 -55
  140. data/resources/locales/en-GB/languages.yml +102 -73
  141. data/resources/locales/en-GB/lists.yml +1 -1
  142. data/resources/locales/en-GB/numbers.yml +74 -25
  143. data/resources/locales/en-GB/plural_rules.yml +10 -0
  144. data/resources/locales/en-GB/plurals.yml +18 -4
  145. data/resources/locales/en-GB/territories.yml +5 -5
  146. data/resources/locales/en-IE/calendars.yml +12 -2
  147. data/resources/locales/en-IE/currencies.yml +49 -9
  148. data/resources/locales/en-IE/languages.yml +99 -70
  149. data/resources/locales/en-IE/numbers.yml +74 -25
  150. data/resources/locales/en-IE/plural_rules.yml +10 -0
  151. data/resources/locales/en-IE/plurals.yml +18 -4
  152. data/resources/locales/en-IE/territories.yml +15 -15
  153. data/resources/locales/en-SG/calendars.yml +15 -5
  154. data/resources/locales/en-SG/currencies.yml +50 -10
  155. data/resources/locales/en-SG/languages.yml +99 -70
  156. data/resources/locales/en-SG/numbers.yml +74 -25
  157. data/resources/locales/en-SG/plural_rules.yml +10 -0
  158. data/resources/locales/en-SG/plurals.yml +18 -4
  159. data/resources/locales/en-SG/territories.yml +15 -15
  160. data/resources/locales/en-ZA/calendars.yml +12 -2
  161. data/resources/locales/en-ZA/currencies.yml +48 -9
  162. data/resources/locales/en-ZA/languages.yml +99 -70
  163. data/resources/locales/en-ZA/numbers.yml +74 -25
  164. data/resources/locales/en-ZA/plural_rules.yml +10 -0
  165. data/resources/locales/en-ZA/plurals.yml +18 -4
  166. data/resources/locales/en-ZA/territories.yml +15 -15
  167. data/resources/locales/en/calendars.yml +12 -2
  168. data/resources/locales/en/currencies.yml +49 -9
  169. data/resources/locales/en/languages.yml +99 -70
  170. data/resources/locales/en/numbers.yml +74 -25
  171. data/resources/locales/en/plural_rules.yml +10 -0
  172. data/resources/locales/en/plurals.yml +18 -4
  173. data/resources/locales/en/rbnf.yml +1 -26
  174. data/resources/locales/en/territories.yml +15 -15
  175. data/resources/locales/es-419/calendars.yml +101 -87
  176. data/resources/locales/es-419/currencies.yml +276 -276
  177. data/resources/locales/es-419/languages.yml +26 -90
  178. data/resources/locales/es-419/lists.yml +4 -4
  179. data/resources/locales/es-419/numbers.yml +74 -25
  180. data/resources/locales/es-419/plural_rules.yml +7 -0
  181. data/resources/locales/es-419/plurals.yml +13 -3
  182. data/resources/locales/es-419/rbnf.yml +1 -1192
  183. data/resources/locales/es-419/territories.yml +4 -4
  184. data/resources/locales/es-CO/calendars.yml +42 -28
  185. data/resources/locales/es-CO/currencies.yml +258 -258
  186. data/resources/locales/es-CO/languages.yml +22 -86
  187. data/resources/locales/es-CO/lists.yml +4 -4
  188. data/resources/locales/es-CO/numbers.yml +74 -25
  189. data/resources/locales/es-CO/plural_rules.yml +7 -0
  190. data/resources/locales/es-CO/plurals.yml +13 -3
  191. data/resources/locales/es-CO/rbnf.yml +1 -1
  192. data/resources/locales/es-CO/territories.yml +2 -2
  193. data/resources/locales/es-MX/calendars.yml +121 -107
  194. data/resources/locales/es-MX/currencies.yml +41 -136
  195. data/resources/locales/es-MX/languages.yml +27 -91
  196. data/resources/locales/es-MX/numbers.yml +76 -27
  197. data/resources/locales/es-MX/plural_rules.yml +7 -0
  198. data/resources/locales/es-MX/plurals.yml +13 -3
  199. data/resources/locales/es-MX/rbnf.yml +1 -1
  200. data/resources/locales/es-MX/territories.yml +7 -7
  201. data/resources/locales/es-US/calendars.yml +56 -48
  202. data/resources/locales/es-US/currencies.yml +259 -259
  203. data/resources/locales/es-US/languages.yml +22 -86
  204. data/resources/locales/es-US/lists.yml +4 -4
  205. data/resources/locales/es-US/numbers.yml +75 -26
  206. data/resources/locales/es-US/plural_rules.yml +7 -0
  207. data/resources/locales/es-US/plurals.yml +13 -3
  208. data/resources/locales/es-US/rbnf.yml +1 -1
  209. data/resources/locales/es-US/territories.yml +2 -2
  210. data/resources/locales/es/calendars.yml +38 -24
  211. data/resources/locales/es/currencies.yml +259 -259
  212. data/resources/locales/es/languages.yml +22 -86
  213. data/resources/locales/es/lists.yml +4 -4
  214. data/resources/locales/es/numbers.yml +75 -26
  215. data/resources/locales/es/plural_rules.yml +7 -0
  216. data/resources/locales/es/plurals.yml +13 -3
  217. data/resources/locales/es/rbnf.yml +8 -81
  218. data/resources/locales/es/territories.yml +2 -2
  219. data/resources/locales/eu/calendars.yml +72 -55
  220. data/resources/locales/eu/currencies.yml +135 -450
  221. data/resources/locales/eu/languages.yml +79 -414
  222. data/resources/locales/eu/lists.yml +4 -4
  223. data/resources/locales/eu/numbers.yml +74 -25
  224. data/resources/locales/eu/plural_rules.yml +7 -0
  225. data/resources/locales/eu/plurals.yml +13 -3
  226. data/resources/locales/eu/territories.yml +2 -2
  227. data/resources/locales/fa/calendars.yml +27 -12
  228. data/resources/locales/fa/currencies.yml +46 -454
  229. data/resources/locales/fa/languages.yml +71 -153
  230. data/resources/locales/fa/lists.yml +4 -4
  231. data/resources/locales/fa/numbers.yml +74 -25
  232. data/resources/locales/fa/plural_rules.yml +7 -0
  233. data/resources/locales/fa/plurals.yml +13 -3
  234. data/resources/locales/fa/territories.yml +4 -4
  235. data/resources/locales/fi/calendars.yml +20 -5
  236. data/resources/locales/fi/currencies.yml +287 -50
  237. data/resources/locales/fi/languages.yml +99 -70
  238. data/resources/locales/fi/numbers.yml +73 -24
  239. data/resources/locales/fi/plural_rules.yml +7 -0
  240. data/resources/locales/fi/plurals.yml +13 -4
  241. data/resources/locales/fi/territories.yml +1 -1
  242. data/resources/locales/fil/calendars.yml +29 -15
  243. data/resources/locales/fil/currencies.yml +144 -489
  244. data/resources/locales/fil/languages.yml +12 -339
  245. data/resources/locales/fil/lists.yml +7 -7
  246. data/resources/locales/fil/numbers.yml +74 -25
  247. data/resources/locales/fil/plural_rules.yml +8 -0
  248. data/resources/locales/fil/plurals.yml +17 -4
  249. data/resources/locales/fil/territories.yml +2 -2
  250. data/resources/locales/fr-BE/calendars.yml +68 -53
  251. data/resources/locales/fr-BE/currencies.yml +202 -82
  252. data/resources/locales/fr-BE/languages.yml +8 -71
  253. data/resources/locales/fr-BE/numbers.yml +74 -25
  254. data/resources/locales/fr-BE/plural_rules.yml +8 -0
  255. data/resources/locales/fr-BE/plurals.yml +15 -3
  256. data/resources/locales/fr-BE/territories.yml +7 -7
  257. data/resources/locales/fr-CA/calendars.yml +25 -10
  258. data/resources/locales/fr-CA/currencies.yml +250 -130
  259. data/resources/locales/fr-CA/languages.yml +11 -74
  260. data/resources/locales/fr-CA/numbers.yml +74 -25
  261. data/resources/locales/fr-CA/plural_rules.yml +8 -0
  262. data/resources/locales/fr-CA/plurals.yml +15 -3
  263. data/resources/locales/fr-CA/territories.yml +16 -16
  264. data/resources/locales/fr-CH/calendars.yml +68 -53
  265. data/resources/locales/fr-CH/currencies.yml +201 -82
  266. data/resources/locales/fr-CH/languages.yml +8 -71
  267. data/resources/locales/fr-CH/numbers.yml +74 -25
  268. data/resources/locales/fr-CH/plural_rules.yml +8 -0
  269. data/resources/locales/fr-CH/plurals.yml +15 -3
  270. data/resources/locales/fr-CH/territories.yml +7 -7
  271. data/resources/locales/fr/calendars.yml +68 -53
  272. data/resources/locales/fr/currencies.yml +202 -82
  273. data/resources/locales/fr/languages.yml +8 -71
  274. data/resources/locales/fr/numbers.yml +74 -25
  275. data/resources/locales/fr/plural_rules.yml +8 -0
  276. data/resources/locales/fr/plurals.yml +15 -3
  277. data/resources/locales/fr/territories.yml +7 -7
  278. data/resources/locales/ga/calendars.yml +136 -45
  279. data/resources/locales/ga/currencies.yml +1238 -587
  280. data/resources/locales/ga/languages.yml +176 -468
  281. data/resources/locales/ga/lists.yml +4 -4
  282. data/resources/locales/ga/numbers.yml +148 -24
  283. data/resources/locales/ga/plural_rules.yml +10 -0
  284. data/resources/locales/ga/plurals.yml +17 -5
  285. data/resources/locales/ga/territories.yml +56 -56
  286. data/resources/locales/gl/calendars.yml +26 -13
  287. data/resources/locales/gl/currencies.yml +378 -582
  288. data/resources/locales/gl/languages.yml +71 -392
  289. data/resources/locales/gl/lists.yml +8 -8
  290. data/resources/locales/gl/numbers.yml +74 -25
  291. data/resources/locales/gl/plural_rules.yml +7 -0
  292. data/resources/locales/gl/plurals.yml +13 -4
  293. data/resources/locales/gl/territories.yml +2 -2
  294. data/resources/locales/he/calendars.yml +53 -32
  295. data/resources/locales/he/currencies.yml +585 -487
  296. data/resources/locales/he/languages.yml +15 -78
  297. data/resources/locales/he/lists.yml +8 -8
  298. data/resources/locales/he/numbers.yml +121 -24
  299. data/resources/locales/he/plural_rules.yml +9 -0
  300. data/resources/locales/he/plurals.yml +16 -6
  301. data/resources/locales/he/rbnf.yml +0 -3
  302. data/resources/locales/he/territories.yml +4 -4
  303. data/resources/locales/hi/calendars.yml +54 -41
  304. data/resources/locales/hi/currencies.yml +155 -428
  305. data/resources/locales/hi/languages.yml +52 -141
  306. data/resources/locales/hi/lists.yml +4 -4
  307. data/resources/locales/hi/numbers.yml +74 -25
  308. data/resources/locales/hi/plural_rules.yml +11 -0
  309. data/resources/locales/hi/plurals.yml +19 -3
  310. data/resources/locales/hi/rbnf.yml +52 -1
  311. data/resources/locales/hi/territories.yml +8 -8
  312. data/resources/locales/hr/calendars.yml +30 -16
  313. data/resources/locales/hr/currencies.yml +306 -66
  314. data/resources/locales/hr/languages.yml +12 -76
  315. data/resources/locales/hr/numbers.yml +97 -24
  316. data/resources/locales/hr/plural_rules.yml +8 -0
  317. data/resources/locales/hr/plurals.yml +16 -8
  318. data/resources/locales/hr/territories.yml +1 -1
  319. data/resources/locales/hu/calendars.yml +25 -10
  320. data/resources/locales/hu/currencies.yml +139 -182
  321. data/resources/locales/hu/languages.yml +8 -72
  322. data/resources/locales/hu/lists.yml +4 -4
  323. data/resources/locales/hu/numbers.yml +73 -24
  324. data/resources/locales/hu/plural_rules.yml +8 -0
  325. data/resources/locales/hu/plurals.yml +15 -3
  326. data/resources/locales/hu/territories.yml +1 -1
  327. data/resources/locales/id/calendars.yml +22 -7
  328. data/resources/locales/id/currencies.yml +323 -192
  329. data/resources/locales/id/languages.yml +36 -71
  330. data/resources/locales/id/numbers.yml +50 -26
  331. data/resources/locales/id/plural_rules.yml +6 -0
  332. data/resources/locales/id/plurals.yml +11 -3
  333. data/resources/locales/id/rbnf.yml +4 -4
  334. data/resources/locales/id/territories.yml +2 -2
  335. data/resources/locales/is/calendars.yml +24 -9
  336. data/resources/locales/is/currencies.yml +145 -336
  337. data/resources/locales/is/languages.yml +57 -163
  338. data/resources/locales/is/numbers.yml +73 -24
  339. data/resources/locales/is/plural_rules.yml +7 -0
  340. data/resources/locales/is/plurals.yml +13 -5
  341. data/resources/locales/is/territories.yml +5 -5
  342. data/resources/locales/it-CH/calendars.yml +41 -26
  343. data/resources/locales/it-CH/currencies.yml +180 -274
  344. data/resources/locales/it-CH/languages.yml +106 -83
  345. data/resources/locales/it-CH/lists.yml +6 -6
  346. data/resources/locales/it-CH/numbers.yml +73 -24
  347. data/resources/locales/it-CH/plural_rules.yml +8 -0
  348. data/resources/locales/it-CH/plurals.yml +15 -4
  349. data/resources/locales/it-CH/territories.yml +9 -9
  350. data/resources/locales/it/calendars.yml +43 -28
  351. data/resources/locales/it/currencies.yml +181 -274
  352. data/resources/locales/it/languages.yml +106 -83
  353. data/resources/locales/it/lists.yml +6 -6
  354. data/resources/locales/it/numbers.yml +73 -24
  355. data/resources/locales/it/plural_rules.yml +8 -0
  356. data/resources/locales/it/plurals.yml +15 -4
  357. data/resources/locales/it/territories.yml +9 -9
  358. data/resources/locales/ja/calendars.yml +24 -9
  359. data/resources/locales/ja/currencies.yml +286 -48
  360. data/resources/locales/ja/languages.yml +106 -83
  361. data/resources/locales/ja/lists.yml +4 -4
  362. data/resources/locales/ja/numbers.yml +50 -26
  363. data/resources/locales/ja/plural_rules.yml +6 -0
  364. data/resources/locales/ja/plurals.yml +11 -3
  365. data/resources/locales/ja/territories.yml +2 -2
  366. data/resources/locales/ko/calendars.yml +63 -16
  367. data/resources/locales/ko/currencies.yml +286 -347
  368. data/resources/locales/ko/languages.yml +27 -76
  369. data/resources/locales/ko/numbers.yml +50 -26
  370. data/resources/locales/ko/plural_rules.yml +6 -0
  371. data/resources/locales/ko/plurals.yml +11 -3
  372. data/resources/locales/ko/territories.yml +4 -4
  373. data/resources/locales/lv/calendars.yml +34 -19
  374. data/resources/locales/lv/currencies.yml +155 -366
  375. data/resources/locales/lv/languages.yml +7 -71
  376. data/resources/locales/lv/numbers.yml +99 -26
  377. data/resources/locales/lv/plural_rules.yml +8 -0
  378. data/resources/locales/lv/plurals.yml +16 -9
  379. data/resources/locales/lv/territories.yml +2 -2
  380. data/resources/locales/ms/calendars.yml +28 -14
  381. data/resources/locales/ms/currencies.yml +185 -500
  382. data/resources/locales/ms/languages.yml +27 -297
  383. data/resources/locales/ms/lists.yml +6 -6
  384. data/resources/locales/ms/numbers.yml +50 -26
  385. data/resources/locales/ms/plural_rules.yml +7 -0
  386. data/resources/locales/ms/plurals.yml +13 -3
  387. data/resources/locales/ms/territories.yml +6 -6
  388. data/resources/locales/nb/calendars.yml +21 -6
  389. data/resources/locales/nb/currencies.yml +271 -44
  390. data/resources/locales/nb/languages.yml +14 -78
  391. data/resources/locales/nb/lists.yml +4 -4
  392. data/resources/locales/nb/numbers.yml +73 -24
  393. data/resources/locales/nb/plural_rules.yml +7 -0
  394. data/resources/locales/nb/plurals.yml +13 -3
  395. data/resources/locales/nb/territories.yml +6 -6
  396. data/resources/locales/nl/calendars.yml +63 -48
  397. data/resources/locales/nl/currencies.yml +294 -56
  398. data/resources/locales/nl/languages.yml +149 -121
  399. data/resources/locales/nl/numbers.yml +74 -25
  400. data/resources/locales/nl/plural_rules.yml +7 -0
  401. data/resources/locales/nl/plurals.yml +13 -4
  402. data/resources/locales/nl/territories.yml +9 -9
  403. data/resources/locales/pl/calendars.yml +23 -9
  404. data/resources/locales/pl/currencies.yml +147 -226
  405. data/resources/locales/pl/languages.yml +102 -73
  406. data/resources/locales/pl/numbers.yml +122 -25
  407. data/resources/locales/pl/plural_rules.yml +9 -0
  408. data/resources/locales/pl/plurals.yml +17 -9
  409. data/resources/locales/pl/rbnf.yml +17 -159
  410. data/resources/locales/pl/territories.yml +1 -1
  411. data/resources/locales/pt/calendars.yml +26 -12
  412. data/resources/locales/pt/currencies.yml +182 -91
  413. data/resources/locales/pt/languages.yml +72 -137
  414. data/resources/locales/pt/numbers.yml +74 -25
  415. data/resources/locales/pt/plural_rules.yml +7 -0
  416. data/resources/locales/pt/plurals.yml +13 -5
  417. data/resources/locales/pt/territories.yml +9 -9
  418. data/resources/locales/ro/calendars.yml +63 -49
  419. data/resources/locales/ro/currencies.yml +209 -291
  420. data/resources/locales/ro/languages.yml +12 -76
  421. data/resources/locales/ro/numbers.yml +98 -25
  422. data/resources/locales/ro/plural_rules.yml +9 -0
  423. data/resources/locales/ro/plurals.yml +17 -6
  424. data/resources/locales/ro/territories.yml +3 -3
  425. data/resources/locales/ru/calendars.yml +55 -41
  426. data/resources/locales/ru/currencies.yml +334 -256
  427. data/resources/locales/ru/languages.yml +8 -72
  428. data/resources/locales/ru/lists.yml +5 -5
  429. data/resources/locales/ru/numbers.yml +122 -24
  430. data/resources/locales/ru/plural_rules.yml +9 -0
  431. data/resources/locales/ru/plurals.yml +17 -7
  432. data/resources/locales/ru/rbnf.yml +15 -105
  433. data/resources/locales/ru/territories.yml +7 -7
  434. data/resources/locales/sk/calendars.yml +89 -51
  435. data/resources/locales/sk/currencies.yml +440 -415
  436. data/resources/locales/sk/languages.yml +50 -114
  437. data/resources/locales/sk/lists.yml +4 -4
  438. data/resources/locales/sk/numbers.yml +122 -25
  439. data/resources/locales/sk/plural_rules.yml +9 -0
  440. data/resources/locales/sk/plurals.yml +16 -6
  441. data/resources/locales/sk/territories.yml +18 -18
  442. data/resources/locales/sq/calendars.yml +72 -58
  443. data/resources/locales/sq/currencies.yml +86 -464
  444. data/resources/locales/sq/languages.yml +222 -579
  445. data/resources/locales/sq/lists.yml +4 -4
  446. data/resources/locales/sq/numbers.yml +73 -24
  447. data/resources/locales/sq/plural_rules.yml +9 -0
  448. data/resources/locales/sq/plurals.yml +16 -3
  449. data/resources/locales/sq/territories.yml +16 -17
  450. data/resources/locales/sr/calendars.yml +30 -16
  451. data/resources/locales/sr/currencies.yml +202 -116
  452. data/resources/locales/sr/languages.yml +200 -298
  453. data/resources/locales/sr/lists.yml +4 -4
  454. data/resources/locales/sr/numbers.yml +98 -25
  455. data/resources/locales/sr/plural_rules.yml +8 -0
  456. data/resources/locales/sr/plurals.yml +16 -8
  457. data/resources/locales/sr/territories.yml +20 -20
  458. data/resources/locales/sv/calendars.yml +46 -31
  459. data/resources/locales/sv/currencies.yml +213 -105
  460. data/resources/locales/sv/languages.yml +76 -73
  461. data/resources/locales/sv/numbers.yml +73 -25
  462. data/resources/locales/sv/plural_rules.yml +8 -0
  463. data/resources/locales/sv/plurals.yml +16 -4
  464. data/resources/locales/sv/rbnf.yml +1 -1
  465. data/resources/locales/sv/territories.yml +1 -1
  466. data/resources/locales/ta/calendars.yml +37 -23
  467. data/resources/locales/ta/currencies.yml +328 -643
  468. data/resources/locales/ta/languages.yml +94 -177
  469. data/resources/locales/ta/numbers.yml +74 -25
  470. data/resources/locales/ta/plural_rules.yml +7 -0
  471. data/resources/locales/ta/plurals.yml +13 -3
  472. data/resources/locales/ta/territories.yml +34 -34
  473. data/resources/locales/th/calendars.yml +33 -6
  474. data/resources/locales/th/currencies.yml +272 -187
  475. data/resources/locales/th/languages.yml +102 -76
  476. data/resources/locales/th/numbers.yml +50 -26
  477. data/resources/locales/th/plural_rules.yml +6 -0
  478. data/resources/locales/th/plurals.yml +11 -3
  479. data/resources/locales/th/territories.yml +2 -2
  480. data/resources/locales/tr/calendars.yml +25 -11
  481. data/resources/locales/tr/currencies.yml +365 -199
  482. data/resources/locales/tr/languages.yml +106 -77
  483. data/resources/locales/tr/numbers.yml +74 -25
  484. data/resources/locales/tr/plural_rules.yml +7 -0
  485. data/resources/locales/tr/plurals.yml +13 -3
  486. data/resources/locales/tr/territories.yml +5 -5
  487. data/resources/locales/uk/calendars.yml +24 -9
  488. data/resources/locales/uk/currencies.yml +139 -207
  489. data/resources/locales/uk/languages.yml +19 -94
  490. data/resources/locales/uk/lists.yml +6 -6
  491. data/resources/locales/uk/numbers.yml +121 -24
  492. data/resources/locales/uk/plural_rules.yml +10 -0
  493. data/resources/locales/uk/plurals.yml +19 -9
  494. data/resources/locales/uk/territories.yml +18 -18
  495. data/resources/locales/ur/calendars.yml +38 -16
  496. data/resources/locales/ur/currencies.yml +273 -577
  497. data/resources/locales/ur/languages.yml +76 -405
  498. data/resources/locales/ur/lists.yml +7 -7
  499. data/resources/locales/ur/numbers.yml +75 -26
  500. data/resources/locales/ur/plural_rules.yml +7 -0
  501. data/resources/locales/ur/plurals.yml +13 -4
  502. data/resources/locales/ur/territories.yml +1 -1
  503. data/resources/locales/vi/calendars.yml +29 -14
  504. data/resources/locales/vi/currencies.yml +273 -195
  505. data/resources/locales/vi/languages.yml +20 -94
  506. data/resources/locales/vi/lists.yml +2 -2
  507. data/resources/locales/vi/numbers.yml +49 -25
  508. data/resources/locales/vi/plural_rules.yml +7 -0
  509. data/resources/locales/vi/plurals.yml +13 -3
  510. data/resources/locales/vi/territories.yml +8 -8
  511. data/resources/locales/zh-Hant/calendars.yml +28 -13
  512. data/resources/locales/zh-Hant/currencies.yml +368 -134
  513. data/resources/locales/zh-Hant/languages.yml +119 -90
  514. data/resources/locales/zh-Hant/lists.yml +4 -4
  515. data/resources/locales/zh-Hant/numbers.yml +50 -26
  516. data/resources/locales/zh-Hant/plural_rules.yml +6 -0
  517. data/resources/locales/zh-Hant/plurals.yml +11 -3
  518. data/resources/locales/zh-Hant/territories.yml +9 -9
  519. data/resources/locales/zh/calendars.yml +20 -5
  520. data/resources/locales/zh/currencies.yml +372 -189
  521. data/resources/locales/zh/languages.yml +7 -71
  522. data/resources/locales/zh/lists.yml +4 -4
  523. data/resources/locales/zh/numbers.yml +50 -26
  524. data/resources/locales/zh/plural_rules.yml +6 -0
  525. data/resources/locales/zh/plurals.yml +11 -3
  526. data/resources/locales/zh/rbnf.yml +46 -0
  527. data/resources/shared/currency_digits_and_rounding.yml +8 -2
  528. data/resources/shared/numbering_systems.yml +3 -0
  529. data/resources/shared/postal_codes.yml +320 -1275
  530. data/resources/shared/rbnf_root.yml +65 -16
  531. data/resources/shared/territories_containment.yml +1 -0
  532. data/resources/uli/segments/de.yml +102 -0
  533. data/resources/uli/segments/es.yml +33 -0
  534. data/resources/uli/segments/fr.yml +21 -0
  535. data/resources/uli/segments/it.yml +11 -0
  536. data/spec/data_readers/number_data_reader_spec.rb +25 -0
  537. data/spec/formatters/list_formatter_spec.rb +2 -2
  538. data/spec/formatters/numbers/abbreviated/abbreviated_number_formatter_spec.rb +11 -17
  539. data/spec/formatters/numbers/abbreviated/long_decimal_formatter_spec.rb +80 -31
  540. data/spec/formatters/numbers/abbreviated/short_decimal_formatter_spec.rb +40 -9
  541. data/spec/formatters/numbers/currency_formatter_spec.rb +1 -1
  542. data/spec/formatters/numbers/rbnf/allowed_failures.yml +47 -35
  543. data/spec/formatters/numbers/rbnf/locales/bn/rbnf_test.yml +1634 -1283
  544. data/spec/formatters/numbers/rbnf/locales/cy/rbnf_test.yml +42 -42
  545. data/spec/formatters/numbers/rbnf/locales/de-CH/rbnf_test.yml +702 -0
  546. data/spec/formatters/numbers/rbnf/locales/de/rbnf_test.yml +702 -0
  547. data/spec/formatters/numbers/rbnf/locales/es-419/rbnf_test.yml +14 -14
  548. data/spec/formatters/numbers/rbnf/locales/es-CO/rbnf_test.yml +14 -14
  549. data/spec/formatters/numbers/rbnf/locales/es-MX/rbnf_test.yml +14 -14
  550. data/spec/formatters/numbers/rbnf/locales/es-US/rbnf_test.yml +14 -14
  551. data/spec/formatters/numbers/rbnf/locales/es/rbnf_test.yml +54 -54
  552. data/spec/formatters/numbers/rbnf/locales/eu/rbnf_test.yml +1634 -1283
  553. data/spec/formatters/numbers/rbnf/locales/fr-CH/rbnf_test.yml +32 -32
  554. data/spec/formatters/numbers/rbnf/locales/gl/rbnf_test.yml +1634 -1283
  555. data/spec/formatters/numbers/rbnf/locales/he/rbnf_test.yml +105 -105
  556. data/spec/formatters/numbers/rbnf/locales/hi/rbnf_test.yml +350 -116
  557. data/spec/formatters/numbers/rbnf/locales/sv/rbnf_test.yml +24 -24
  558. data/spec/formatters/numbers/rbnf/locales/ur/rbnf_test.yml +1634 -1283
  559. data/spec/formatters/numbers/rbnf/locales/zh/rbnf_test.yml +117 -0
  560. data/spec/formatters/plurals/rules_spec.rb +37 -14
  561. data/spec/localized/localized_number_spec.rb +2 -1
  562. data/spec/parsers/number_parser_spec.rb +5 -5
  563. data/spec/shared/calendar_spec.rb +3 -3
  564. data/spec/shared/postal_codes_spec.rb +16 -0
  565. data/spec/shared/territories_spec.rb +2 -2
  566. data/spec/spec_helper.rb +1 -1
  567. data/twitter_cldr.gemspec +1 -0
  568. metadata +364 -285
  569. data/resources/custom/locales/hu/plurals.yml +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bac470ce4e512aac2ad6466f8dd297e7f82a3f03
4
- data.tar.gz: b12587637965f791f2c8bedb6fee338d4631aeaf
3
+ metadata.gz: accacbf47c61c3008a7cdae91acde6d4bb848bc9
4
+ data.tar.gz: 112cdf6e94bc614b5677289ee345b4ea38bd55e0
5
5
  SHA512:
6
- metadata.gz: 2d166f1a1383b5c950edef4bcf2fd1f750fc568c3b29ec896f923b22258150d227b19210e3b6e3e53700703f3b34ef3499b0b5d799ace421dff15b924dd04f6a
7
- data.tar.gz: d8e91fbcd4cb123bd8eacc3e802c8e9d69563462cb9d0f14d3678ed389c4ca7b5457c3d50566460e474121be96e0e8b1b3ed59cab11862d140c2afcb51f57e93
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.5'
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 => 'svenfuchs/ruby-cldr', :ref => 'cddf44b885'
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-52_1.jar'
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 = '21.0' # release date: 2012-02-10
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 pattern(number = nil)
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 = traverse(path)
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)] || pattern
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[:minus] || '-'}#{pattern}"
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
- NUMBER_MIN <= number && number < NUMBER_MAX
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
- FORMAT_REGEX = /^0+$/
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
- if integer_format.format =~ FORMAT_REGEX
17
- factor = [0, number.to_i.to_s.length - integer_format.format.length].max
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
@@ -27,4 +27,4 @@ module TwitterCldr
27
27
 
28
28
  end
29
29
  end
30
- end
30
+ 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
- def all
14
- all_for(TwitterCldr.locale)
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
- get_resource(locale)[:keys]
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
- get_resource(locale)[:rule].call(number)
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] ||= eval(TwitterCldr.get_locale_resource(locale, :plurals)[locale])[locale][:i18n][:plural]
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