twitter_cldr 3.1.1 → 3.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +6 -22
- data/History.txt +3 -0
- data/NOTICE +3 -96
- data/README.md +23 -40
- data/Rakefile +12 -24
- data/lib/twitter_cldr.rb +1 -2
- data/lib/twitter_cldr/localized/localized_date.rb +1 -1
- data/lib/twitter_cldr/localized/localized_datetime.rb +1 -1
- data/lib/twitter_cldr/localized/localized_string.rb +7 -2
- data/lib/twitter_cldr/parsers/unicode_regex/component.rb +1 -4
- data/lib/twitter_cldr/resources/locales_resources_importer.rb +3 -7
- data/lib/twitter_cldr/resources/readme_renderer.rb +0 -7
- data/lib/twitter_cldr/shared/calendar.rb +2 -2
- data/lib/twitter_cldr/shared/postal_codes.rb +1 -9
- data/lib/twitter_cldr/shared/unicode_regex.rb +1 -9
- data/lib/twitter_cldr/tokenizers/numbers/rbnf_tokenizer.rb +1 -5
- data/lib/twitter_cldr/utils.rb +0 -2
- data/lib/twitter_cldr/utils/yaml.rb +0 -2
- data/lib/twitter_cldr/version.rb +1 -1
- data/resources/locales/af/calendars.yml +181 -181
- data/resources/locales/af/currencies.yml +166 -166
- data/resources/locales/af/languages.yml +217 -217
- data/resources/locales/af/layout.yml +1 -1
- data/resources/locales/af/numbers.yml +30 -30
- data/resources/locales/af/rbnf.yml +52 -52
- data/resources/locales/af/territories.yml +210 -210
- data/resources/locales/ar/calendars.yml +181 -181
- data/resources/locales/ar/currencies.yml +190 -190
- data/resources/locales/ar/languages.yml +413 -413
- data/resources/locales/ar/layout.yml +1 -1
- data/resources/locales/ar/numbers.yml +84 -84
- data/resources/locales/ar/rbnf.yml +59 -59
- data/resources/locales/ar/territories.yml +179 -179
- data/resources/locales/be/calendars.yml +125 -125
- data/resources/locales/be/currencies.yml +99 -99
- data/resources/locales/be/languages.yml +119 -119
- data/resources/locales/be/layout.yml +1 -1
- data/resources/locales/be/numbers.yml +24 -24
- data/resources/locales/be/rbnf.yml +157 -157
- data/resources/locales/be/territories.yml +185 -185
- data/resources/locales/bg/calendars.yml +171 -171
- data/resources/locales/bg/currencies.yml +170 -170
- data/resources/locales/bg/languages.yml +437 -437
- data/resources/locales/bg/layout.yml +1 -1
- data/resources/locales/bg/numbers.yml +35 -35
- data/resources/locales/bg/rbnf.yml +34 -34
- data/resources/locales/bg/territories.yml +181 -181
- data/resources/locales/bn/calendars.yml +188 -188
- data/resources/locales/bn/currencies.yml +168 -168
- data/resources/locales/bn/languages.yml +417 -417
- data/resources/locales/bn/layout.yml +1 -1
- data/resources/locales/bn/numbers.yml +35 -35
- data/resources/locales/bn/territories.yml +185 -185
- data/resources/locales/ca/calendars.yml +177 -177
- data/resources/locales/ca/currencies.yml +302 -302
- data/resources/locales/ca/languages.yml +439 -439
- data/resources/locales/ca/layout.yml +1 -1
- data/resources/locales/ca/numbers.yml +35 -35
- data/resources/locales/ca/rbnf.yml +160 -160
- data/resources/locales/ca/territories.yml +179 -179
- data/resources/locales/cs/calendars.yml +150 -150
- data/resources/locales/cs/currencies.yml +314 -314
- data/resources/locales/cs/languages.yml +506 -506
- data/resources/locales/cs/layout.yml +1 -1
- data/resources/locales/cs/numbers.yml +60 -60
- data/resources/locales/cs/rbnf.yml +40 -40
- data/resources/locales/cs/territories.yml +188 -188
- data/resources/locales/cy/calendars.yml +149 -149
- data/resources/locales/cy/currencies.yml +105 -105
- data/resources/locales/cy/languages.yml +330 -330
- data/resources/locales/cy/layout.yml +1 -1
- data/resources/locales/cy/numbers.yml +83 -83
- data/resources/locales/cy/rbnf.yml +54 -54
- data/resources/locales/cy/territories.yml +164 -164
- data/resources/locales/da/calendars.yml +182 -182
- data/resources/locales/da/currencies.yml +177 -177
- data/resources/locales/da/languages.yml +484 -484
- data/resources/locales/da/layout.yml +1 -1
- data/resources/locales/da/numbers.yml +35 -35
- data/resources/locales/da/rbnf.yml +38 -38
- data/resources/locales/da/territories.yml +206 -206
- data/resources/locales/de-CH/calendars.yml +192 -192
- data/resources/locales/de-CH/currencies.yml +428 -428
- data/resources/locales/de-CH/languages.yml +575 -575
- data/resources/locales/de-CH/layout.yml +1 -1
- data/resources/locales/de-CH/numbers.yml +35 -35
- data/resources/locales/de-CH/territories.yml +209 -209
- data/resources/locales/de/calendars.yml +192 -192
- data/resources/locales/de/currencies.yml +428 -428
- data/resources/locales/de/languages.yml +575 -575
- data/resources/locales/de/layout.yml +1 -1
- data/resources/locales/de/numbers.yml +35 -35
- data/resources/locales/de/rbnf.yml +80 -80
- data/resources/locales/de/territories.yml +207 -207
- data/resources/locales/el/calendars.yml +179 -179
- data/resources/locales/el/currencies.yml +162 -162
- data/resources/locales/el/languages.yml +441 -441
- data/resources/locales/el/layout.yml +1 -1
- data/resources/locales/el/numbers.yml +35 -35
- data/resources/locales/el/rbnf.yml +98 -98
- data/resources/locales/el/territories.yml +182 -182
- data/resources/locales/en-150/calendars.yml +105 -105
- data/resources/locales/en-150/currencies.yml +103 -103
- data/resources/locales/en-150/languages.yml +503 -503
- data/resources/locales/en-150/layout.yml +1 -1
- data/resources/locales/en-150/numbers.yml +35 -35
- data/resources/locales/en-150/territories.yml +182 -182
- data/resources/locales/en-AU/calendars.yml +105 -105
- data/resources/locales/en-AU/currencies.yml +103 -103
- data/resources/locales/en-AU/languages.yml +503 -503
- data/resources/locales/en-AU/layout.yml +1 -1
- data/resources/locales/en-AU/numbers.yml +35 -35
- data/resources/locales/en-AU/territories.yml +182 -182
- data/resources/locales/en-CA/calendars.yml +105 -105
- data/resources/locales/en-CA/currencies.yml +103 -103
- data/resources/locales/en-CA/languages.yml +503 -503
- data/resources/locales/en-CA/layout.yml +1 -1
- data/resources/locales/en-CA/numbers.yml +35 -35
- data/resources/locales/en-CA/territories.yml +182 -182
- data/resources/locales/en-GB/calendars.yml +109 -109
- data/resources/locales/en-GB/currencies.yml +250 -250
- data/resources/locales/en-GB/languages.yml +503 -503
- data/resources/locales/en-GB/layout.yml +1 -1
- data/resources/locales/en-GB/numbers.yml +35 -35
- data/resources/locales/en-GB/territories.yml +181 -181
- data/resources/locales/en-IE/calendars.yml +105 -105
- data/resources/locales/en-IE/currencies.yml +103 -103
- data/resources/locales/en-IE/languages.yml +503 -503
- data/resources/locales/en-IE/layout.yml +1 -1
- data/resources/locales/en-IE/numbers.yml +35 -35
- data/resources/locales/en-IE/territories.yml +182 -182
- data/resources/locales/en-SG/calendars.yml +105 -105
- data/resources/locales/en-SG/currencies.yml +103 -103
- data/resources/locales/en-SG/languages.yml +503 -503
- data/resources/locales/en-SG/layout.yml +1 -1
- data/resources/locales/en-SG/numbers.yml +35 -35
- data/resources/locales/en-SG/territories.yml +182 -182
- data/resources/locales/en-ZA/calendars.yml +105 -105
- data/resources/locales/en-ZA/currencies.yml +103 -103
- data/resources/locales/en-ZA/languages.yml +503 -503
- data/resources/locales/en-ZA/layout.yml +1 -1
- data/resources/locales/en-ZA/numbers.yml +36 -36
- data/resources/locales/en-ZA/territories.yml +182 -182
- data/resources/locales/en/calendars.yml +105 -105
- data/resources/locales/en/currencies.yml +103 -103
- data/resources/locales/en/languages.yml +503 -503
- data/resources/locales/en/layout.yml +1 -1
- data/resources/locales/en/numbers.yml +35 -35
- data/resources/locales/en/rbnf.yml +94 -94
- data/resources/locales/en/territories.yml +182 -182
- data/resources/locales/es-419/calendars.yml +170 -170
- data/resources/locales/es-419/currencies.yml +258 -258
- data/resources/locales/es-419/languages.yml +439 -439
- data/resources/locales/es-419/layout.yml +1 -1
- data/resources/locales/es-419/numbers.yml +33 -33
- data/resources/locales/es-419/territories.yml +178 -178
- data/resources/locales/es-CO/calendars.yml +182 -182
- data/resources/locales/es-CO/currencies.yml +258 -258
- data/resources/locales/es-CO/languages.yml +439 -439
- data/resources/locales/es-CO/layout.yml +1 -1
- data/resources/locales/es-CO/numbers.yml +35 -35
- data/resources/locales/es-CO/territories.yml +179 -179
- data/resources/locales/es-MX/calendars.yml +181 -181
- data/resources/locales/es-MX/currencies.yml +194 -194
- data/resources/locales/es-MX/languages.yml +441 -441
- data/resources/locales/es-MX/layout.yml +1 -1
- data/resources/locales/es-MX/numbers.yml +35 -35
- data/resources/locales/es-MX/territories.yml +178 -178
- data/resources/locales/es-US/calendars.yml +185 -185
- data/resources/locales/es-US/currencies.yml +258 -258
- data/resources/locales/es-US/languages.yml +439 -439
- data/resources/locales/es-US/layout.yml +1 -1
- data/resources/locales/es-US/numbers.yml +35 -35
- data/resources/locales/es-US/territories.yml +179 -179
- data/resources/locales/es/calendars.yml +183 -183
- data/resources/locales/es/currencies.yml +258 -258
- data/resources/locales/es/languages.yml +439 -439
- data/resources/locales/es/layout.yml +1 -1
- data/resources/locales/es/numbers.yml +35 -35
- data/resources/locales/es/rbnf.yml +123 -123
- data/resources/locales/es/territories.yml +179 -179
- data/resources/locales/eu/calendars.yml +185 -185
- data/resources/locales/eu/currencies.yml +160 -160
- data/resources/locales/eu/languages.yml +213 -213
- data/resources/locales/eu/layout.yml +1 -1
- data/resources/locales/eu/numbers.yml +29 -29
- data/resources/locales/eu/territories.yml +184 -184
- data/resources/locales/fa/calendars.yml +191 -191
- data/resources/locales/fa/currencies.yml +107 -107
- data/resources/locales/fa/languages.yml +412 -412
- data/resources/locales/fa/layout.yml +1 -1
- data/resources/locales/fa/numbers.yml +36 -36
- data/resources/locales/fa/rbnf.yml +28 -28
- data/resources/locales/fa/territories.yml +187 -187
- data/resources/locales/fi/calendars.yml +186 -186
- data/resources/locales/fi/currencies.yml +316 -316
- data/resources/locales/fi/languages.yml +590 -590
- data/resources/locales/fi/layout.yml +1 -1
- data/resources/locales/fi/numbers.yml +37 -37
- data/resources/locales/fi/rbnf.yml +39 -39
- data/resources/locales/fi/territories.yml +213 -213
- data/resources/locales/fil/calendars.yml +182 -182
- data/resources/locales/fil/currencies.yml +118 -118
- data/resources/locales/fil/languages.yml +214 -214
- data/resources/locales/fil/layout.yml +1 -1
- data/resources/locales/fil/numbers.yml +35 -35
- data/resources/locales/fil/rbnf.yml +35 -35
- data/resources/locales/fil/territories.yml +180 -180
- data/resources/locales/fr-BE/calendars.yml +198 -198
- data/resources/locales/fr-BE/currencies.yml +246 -246
- data/resources/locales/fr-BE/languages.yml +448 -448
- data/resources/locales/fr-BE/layout.yml +1 -1
- data/resources/locales/fr-BE/numbers.yml +35 -35
- data/resources/locales/fr-BE/rbnf.yml +140 -140
- data/resources/locales/fr-BE/territories.yml +195 -195
- data/resources/locales/fr-CA/calendars.yml +199 -199
- data/resources/locales/fr-CA/currencies.yml +252 -252
- data/resources/locales/fr-CA/languages.yml +449 -449
- data/resources/locales/fr-CA/layout.yml +1 -1
- data/resources/locales/fr-CA/numbers.yml +36 -36
- data/resources/locales/fr-CA/territories.yml +196 -196
- data/resources/locales/fr-CH/calendars.yml +200 -200
- data/resources/locales/fr-CH/currencies.yml +246 -246
- data/resources/locales/fr-CH/languages.yml +448 -448
- data/resources/locales/fr-CH/layout.yml +1 -1
- data/resources/locales/fr-CH/numbers.yml +36 -36
- data/resources/locales/fr-CH/rbnf.yml +139 -139
- data/resources/locales/fr-CH/territories.yml +195 -195
- data/resources/locales/fr/calendars.yml +198 -198
- data/resources/locales/fr/currencies.yml +246 -246
- data/resources/locales/fr/languages.yml +448 -448
- data/resources/locales/fr/layout.yml +1 -1
- data/resources/locales/fr/numbers.yml +36 -36
- data/resources/locales/fr/rbnf.yml +145 -145
- data/resources/locales/fr/territories.yml +195 -195
- data/resources/locales/ga/calendars.yml +162 -162
- data/resources/locales/ga/currencies.yml +250 -250
- data/resources/locales/ga/languages.yml +247 -247
- data/resources/locales/ga/layout.yml +1 -1
- data/resources/locales/ga/numbers.yml +71 -71
- data/resources/locales/ga/rbnf.yml +115 -115
- data/resources/locales/ga/territories.yml +78 -78
- data/resources/locales/gl/calendars.yml +183 -183
- data/resources/locales/gl/currencies.yml +169 -169
- data/resources/locales/gl/languages.yml +213 -213
- data/resources/locales/gl/layout.yml +1 -1
- data/resources/locales/gl/numbers.yml +35 -35
- data/resources/locales/gl/territories.yml +180 -180
- data/resources/locales/he/calendars.yml +129 -129
- data/resources/locales/he/currencies.yml +173 -173
- data/resources/locales/he/languages.yml +443 -443
- data/resources/locales/he/layout.yml +1 -1
- data/resources/locales/he/numbers.yml +60 -60
- data/resources/locales/he/rbnf.yml +133 -133
- data/resources/locales/he/territories.yml +179 -179
- data/resources/locales/hi/calendars.yml +185 -185
- data/resources/locales/hi/currencies.yml +160 -160
- data/resources/locales/hi/languages.yml +420 -420
- data/resources/locales/hi/layout.yml +1 -1
- data/resources/locales/hi/numbers.yml +35 -35
- data/resources/locales/hi/rbnf.yml +137 -137
- data/resources/locales/hi/territories.yml +183 -183
- data/resources/locales/hr/calendars.yml +173 -173
- data/resources/locales/hr/currencies.yml +315 -315
- data/resources/locales/hr/languages.yml +457 -457
- data/resources/locales/hr/layout.yml +1 -1
- data/resources/locales/hr/numbers.yml +47 -47
- data/resources/locales/hr/rbnf.yml +63 -63
- data/resources/locales/hr/territories.yml +181 -181
- data/resources/locales/hu/calendars.yml +175 -175
- data/resources/locales/hu/currencies.yml +171 -171
- data/resources/locales/hu/languages.yml +455 -455
- data/resources/locales/hu/layout.yml +1 -1
- data/resources/locales/hu/numbers.yml +36 -36
- data/resources/locales/hu/rbnf.yml +91 -91
- data/resources/locales/hu/territories.yml +212 -212
- data/resources/locales/id/calendars.yml +182 -182
- data/resources/locales/id/currencies.yml +297 -297
- data/resources/locales/id/languages.yml +457 -457
- data/resources/locales/id/layout.yml +1 -1
- data/resources/locales/id/numbers.yml +22 -22
- data/resources/locales/id/rbnf.yml +25 -25
- data/resources/locales/id/territories.yml +181 -181
- data/resources/locales/is/calendars.yml +182 -182
- data/resources/locales/is/currencies.yml +194 -194
- data/resources/locales/is/languages.yml +443 -443
- data/resources/locales/is/layout.yml +1 -1
- data/resources/locales/is/numbers.yml +35 -35
- data/resources/locales/is/rbnf.yml +45 -45
- data/resources/locales/is/territories.yml +212 -212
- data/resources/locales/it-CH/calendars.yml +183 -183
- data/resources/locales/it-CH/currencies.yml +168 -168
- data/resources/locales/it-CH/languages.yml +501 -501
- data/resources/locales/it-CH/layout.yml +1 -1
- data/resources/locales/it-CH/numbers.yml +29 -29
- data/resources/locales/it-CH/territories.yml +184 -184
- data/resources/locales/it/calendars.yml +180 -180
- data/resources/locales/it/currencies.yml +168 -168
- data/resources/locales/it/languages.yml +501 -501
- data/resources/locales/it/layout.yml +1 -1
- data/resources/locales/it/numbers.yml +29 -29
- data/resources/locales/it/rbnf.yml +368 -368
- data/resources/locales/it/territories.yml +184 -184
- data/resources/locales/ja/calendars.yml +195 -195
- data/resources/locales/ja/currencies.yml +353 -353
- data/resources/locales/ja/languages.yml +602 -602
- data/resources/locales/ja/layout.yml +1 -1
- data/resources/locales/ja/numbers.yml +35 -35
- data/resources/locales/ja/rbnf.yml +49 -49
- data/resources/locales/ja/territories.yml +260 -260
- data/resources/locales/ko/calendars.yml +180 -180
- data/resources/locales/ko/currencies.yml +168 -168
- data/resources/locales/ko/languages.yml +455 -455
- data/resources/locales/ko/layout.yml +1 -1
- data/resources/locales/ko/numbers.yml +33 -33
- data/resources/locales/ko/rbnf.yml +136 -136
- data/resources/locales/ko/territories.yml +219 -219
- data/resources/locales/lv/calendars.yml +179 -179
- data/resources/locales/lv/currencies.yml +166 -166
- data/resources/locales/lv/languages.yml +473 -473
- data/resources/locales/lv/layout.yml +1 -1
- data/resources/locales/lv/numbers.yml +48 -48
- data/resources/locales/lv/rbnf.yml +45 -45
- data/resources/locales/lv/territories.yml +202 -202
- data/resources/locales/ms/calendars.yml +181 -181
- data/resources/locales/ms/currencies.yml +163 -163
- data/resources/locales/ms/languages.yml +257 -257
- data/resources/locales/ms/layout.yml +1 -1
- data/resources/locales/ms/numbers.yml +23 -23
- data/resources/locales/ms/rbnf.yml +27 -27
- data/resources/locales/ms/territories.yml +179 -179
- data/resources/locales/nb/calendars.yml +190 -190
- data/resources/locales/nb/currencies.yml +313 -313
- data/resources/locales/nb/languages.yml +480 -480
- data/resources/locales/nb/layout.yml +1 -1
- data/resources/locales/nb/numbers.yml +37 -37
- data/resources/locales/nb/rbnf.yml +38 -38
- data/resources/locales/nb/territories.yml +213 -213
- data/resources/locales/nl/calendars.yml +182 -182
- data/resources/locales/nl/currencies.yml +319 -319
- data/resources/locales/nl/languages.yml +555 -555
- data/resources/locales/nl/layout.yml +1 -1
- data/resources/locales/nl/numbers.yml +35 -35
- data/resources/locales/nl/rbnf.yml +81 -81
- data/resources/locales/nl/territories.yml +215 -215
- data/resources/locales/pl/calendars.yml +176 -176
- data/resources/locales/pl/currencies.yml +175 -175
- data/resources/locales/pl/languages.yml +537 -537
- data/resources/locales/pl/layout.yml +1 -1
- data/resources/locales/pl/numbers.yml +60 -60
- data/resources/locales/pl/rbnf.yml +58 -58
- data/resources/locales/pl/territories.yml +191 -191
- data/resources/locales/pt/calendars.yml +187 -187
- data/resources/locales/pt/currencies.yml +172 -172
- data/resources/locales/pt/languages.yml +442 -442
- data/resources/locales/pt/layout.yml +1 -1
- data/resources/locales/pt/numbers.yml +35 -35
- data/resources/locales/pt/rbnf.yml +75 -75
- data/resources/locales/pt/territories.yml +178 -178
- data/resources/locales/ro/calendars.yml +170 -170
- data/resources/locales/ro/currencies.yml +165 -165
- data/resources/locales/ro/languages.yml +443 -443
- data/resources/locales/ro/layout.yml +1 -1
- data/resources/locales/ro/numbers.yml +47 -47
- data/resources/locales/ro/rbnf.yml +34 -34
- data/resources/locales/ro/territories.yml +178 -178
- data/resources/locales/ru/calendars.yml +174 -174
- data/resources/locales/ru/currencies.yml +176 -176
- data/resources/locales/ru/languages.yml +469 -469
- data/resources/locales/ru/layout.yml +1 -1
- data/resources/locales/ru/numbers.yml +60 -60
- data/resources/locales/ru/rbnf.yml +40 -40
- data/resources/locales/ru/territories.yml +197 -197
- data/resources/locales/sk/calendars.yml +170 -170
- data/resources/locales/sk/currencies.yml +168 -168
- data/resources/locales/sk/languages.yml +439 -439
- data/resources/locales/sk/layout.yml +1 -1
- data/resources/locales/sk/numbers.yml +60 -60
- data/resources/locales/sk/rbnf.yml +40 -40
- data/resources/locales/sk/territories.yml +191 -191
- data/resources/locales/sq/calendars.yml +157 -157
- data/resources/locales/sq/currencies.yml +102 -102
- data/resources/locales/sq/languages.yml +188 -188
- data/resources/locales/sq/layout.yml +1 -1
- data/resources/locales/sq/numbers.yml +36 -36
- data/resources/locales/sq/rbnf.yml +26 -26
- data/resources/locales/sq/territories.yml +180 -180
- data/resources/locales/sr/calendars.yml +185 -185
- data/resources/locales/sr/currencies.yml +171 -171
- data/resources/locales/sr/languages.yml +430 -430
- data/resources/locales/sr/layout.yml +1 -1
- data/resources/locales/sr/numbers.yml +47 -47
- data/resources/locales/sr/rbnf.yml +80 -80
- data/resources/locales/sr/territories.yml +184 -184
- data/resources/locales/sv/calendars.yml +189 -189
- data/resources/locales/sv/currencies.yml +212 -212
- data/resources/locales/sv/languages.yml +541 -541
- data/resources/locales/sv/layout.yml +1 -1
- data/resources/locales/sv/numbers.yml +37 -37
- data/resources/locales/sv/rbnf.yml +149 -149
- data/resources/locales/sv/territories.yml +207 -207
- data/resources/locales/ta/calendars.yml +185 -185
- data/resources/locales/ta/currencies.yml +160 -160
- data/resources/locales/ta/languages.yml +422 -422
- data/resources/locales/ta/layout.yml +1 -1
- data/resources/locales/ta/numbers.yml +35 -35
- data/resources/locales/ta/rbnf.yml +54 -54
- data/resources/locales/ta/territories.yml +184 -184
- data/resources/locales/th/calendars.yml +176 -176
- data/resources/locales/th/currencies.yml +695 -695
- data/resources/locales/th/languages.yml +594 -594
- data/resources/locales/th/layout.yml +1 -1
- data/resources/locales/th/numbers.yml +23 -23
- data/resources/locales/th/rbnf.yml +29 -29
- data/resources/locales/th/territories.yml +253 -253
- data/resources/locales/tr/calendars.yml +179 -179
- data/resources/locales/tr/currencies.yml +268 -268
- data/resources/locales/tr/languages.yml +443 -443
- data/resources/locales/tr/layout.yml +1 -1
- data/resources/locales/tr/numbers.yml +33 -33
- data/resources/locales/tr/rbnf.yml +61 -61
- data/resources/locales/tr/territories.yml +179 -179
- data/resources/locales/uk/calendars.yml +175 -175
- data/resources/locales/uk/currencies.yml +175 -175
- data/resources/locales/uk/languages.yml +467 -467
- data/resources/locales/uk/layout.yml +1 -1
- data/resources/locales/uk/numbers.yml +60 -60
- data/resources/locales/uk/rbnf.yml +40 -40
- data/resources/locales/uk/territories.yml +193 -193
- data/resources/locales/ur/calendars.yml +162 -162
- data/resources/locales/ur/currencies.yml +160 -160
- data/resources/locales/ur/languages.yml +203 -203
- data/resources/locales/ur/layout.yml +1 -1
- data/resources/locales/ur/numbers.yml +36 -36
- data/resources/locales/ur/territories.yml +166 -166
- data/resources/locales/vi/calendars.yml +80 -80
- data/resources/locales/vi/currencies.yml +295 -295
- data/resources/locales/vi/languages.yml +1 -1
- data/resources/locales/vi/layout.yml +1 -1
- data/resources/locales/vi/numbers.yml +23 -23
- data/resources/locales/vi/rbnf.yml +39 -39
- data/resources/locales/vi/territories.yml +158 -158
- data/resources/locales/zh-Hant/calendars.yml +200 -200
- data/resources/locales/zh-Hant/currencies.yml +789 -789
- data/resources/locales/zh-Hant/languages.yml +607 -607
- data/resources/locales/zh-Hant/layout.yml +1 -1
- data/resources/locales/zh-Hant/numbers.yml +34 -34
- data/resources/locales/zh-Hant/rbnf.yml +197 -197
- data/resources/locales/zh-Hant/territories.yml +260 -260
- data/resources/locales/zh/calendars.yml +204 -204
- data/resources/locales/zh/currencies.yml +740 -740
- data/resources/locales/zh/languages.yml +515 -515
- data/resources/locales/zh/layout.yml +1 -1
- data/resources/locales/zh/numbers.yml +35 -35
- data/resources/locales/zh/rbnf.yml +231 -231
- data/resources/locales/zh/territories.yml +260 -260
- data/resources/shared/numbering_systems.yml +118 -118
- data/resources/shared/rbnf_root.yml +239 -239
- data/resources/shared/segments/segments_root.yml +143 -143
- data/resources/shared/territories_containment.yml +304 -304
- data/spec/bidi/bidi_spec.rb +0 -1
- data/spec/core_ext_spec.rb +1 -2
- data/spec/parsers/segmentation_parser_spec.rb +8 -4
- data/spec/parsers/symbol_table_spec.rb +1 -5
- data/spec/parsers/unicode_regex/character_class_spec.rb +5 -3
- data/spec/parsers/unicode_regex/unicode_string_spec.rb +1 -1
- data/spec/shared/unicode_regex_spec.rb +14 -14
- data/spec/spec_helper.rb +3 -12
- data/spec/utils/yaml/yaml_spec.rb +10 -26
- metadata +14 -15
- data/lib/twitter_cldr/utils/interpolation.rb +0 -105
- data/spec/utils/interpolation_spec.rb +0 -124
data/spec/bidi/bidi_spec.rb
CHANGED
data/spec/core_ext_spec.rb
CHANGED
@@ -10,8 +10,7 @@ describe 'Core classes localization' do
|
|
10
10
|
[Array, Bignum, DateTime, Fixnum, Float, String, Symbol, Time].each do |klass|
|
11
11
|
describe klass do
|
12
12
|
it 'has public instance method #localize' do
|
13
|
-
|
14
|
-
expect(klass.public_instance_methods.map(&:to_sym)).to include(:localize)
|
13
|
+
expect(klass.public_instance_methods).to include(:localize)
|
15
14
|
end
|
16
15
|
end
|
17
16
|
end
|
@@ -30,20 +30,24 @@ describe "Segmentation" do
|
|
30
30
|
describe "#parse" do
|
31
31
|
it "should parse a rule with a break" do
|
32
32
|
rule = parse(tokenize("[a-z] ÷ [0-9]"))
|
33
|
-
expect(rule.left.to_regexp_str).to eq("\\A(?:[\\
|
34
|
-
expect(rule.right.to_regexp_str).to eq("\\A(?:[\\
|
33
|
+
expect(rule.left.to_regexp_str).to eq("\\A(?:[\\u{0061}-\\u{007a}])")
|
34
|
+
expect(rule.right.to_regexp_str).to eq("\\A(?:[\\u{0030}-\\u{0039}])")
|
35
35
|
expect(rule.boundary_symbol).to eq(:break)
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should parse a rule with a non-break" do
|
39
39
|
rule = parse(tokenize("[a-z] × [0-9]"))
|
40
|
-
expect(rule.regex.to_regexp_str).to eq(
|
40
|
+
expect(rule.regex.to_regexp_str).to eq(
|
41
|
+
"\\A(?:[\\u{0061}-\\u{007a}])(?:[\\u{0030}-\\u{0039}])"
|
42
|
+
)
|
41
43
|
expect(rule.boundary_symbol).to eq(:no_break)
|
42
44
|
end
|
43
45
|
|
44
46
|
it "should parse a rule containing a variable" do
|
45
47
|
rule = parse(tokenize("$FOO × bar"), :symbol_table => symbol_table)
|
46
|
-
expect(rule.regex.to_regexp_str).to eq(
|
48
|
+
expect(rule.regex.to_regexp_str).to eq(
|
49
|
+
"\\A(?:[\\u{0061}-\\u{0063}])(?:\\u{0062})(?:\\u{0061})(?:\\u{0072})"
|
50
|
+
)
|
47
51
|
expect(rule.boundary_symbol).to eq(:no_break)
|
48
52
|
end
|
49
53
|
end
|
@@ -15,11 +15,7 @@ describe SymbolTable do
|
|
15
15
|
expect(table.fetch(:a)).to eq("b")
|
16
16
|
fetch = lambda { table.fetch(:z) }
|
17
17
|
|
18
|
-
|
19
|
-
expect(fetch).to raise_error(KeyError)
|
20
|
-
else
|
21
|
-
expect(fetch).to raise_error(IndexError)
|
22
|
-
end
|
18
|
+
expect(fetch).to raise_error(KeyError)
|
23
19
|
end
|
24
20
|
end
|
25
21
|
|
@@ -102,17 +102,19 @@ describe UnicodeRegexParser::CharacterClass do
|
|
102
102
|
describe "#to_regexp_str" do
|
103
103
|
it "wraps ranges in square brackets" do
|
104
104
|
char_class = char_class_from(parse(tokenize("[a-z]")))
|
105
|
-
expect(char_class.to_regexp_str).to eq("(?:[\\
|
105
|
+
expect(char_class.to_regexp_str).to eq("(?:[\\u{0061}-\\u{007a}])")
|
106
106
|
end
|
107
107
|
|
108
108
|
it "octal-encodes and wraps sequential characters to isolate bytes" do
|
109
109
|
char_class = char_class_from(parse(tokenize("[{foo}]")))
|
110
|
-
expect(char_class.to_regexp_str).to eq("(?:(?:\\
|
110
|
+
expect(char_class.to_regexp_str).to eq("(?:(?:\\u{0066})(?:\\u{006f})(?:\\u{006f}))")
|
111
111
|
end
|
112
112
|
|
113
113
|
it "combines multiple components with 'or' pipe characters" do
|
114
114
|
char_class = char_class_from(parse(tokenize("[{foo}abc]")))
|
115
|
-
expect(char_class.to_regexp_str).to eq(
|
115
|
+
expect(char_class.to_regexp_str).to eq(
|
116
|
+
"(?:(?:\\u{0066})(?:\\u{006f})(?:\\u{006f})|[\\u{0061}-\\u{0063}])"
|
117
|
+
)
|
116
118
|
end
|
117
119
|
end
|
118
120
|
end
|
@@ -21,7 +21,7 @@ describe UnicodeRegexParser::UnicodeString do
|
|
21
21
|
|
22
22
|
it "should covert the codepoints to a valid regex" do
|
23
23
|
str = UnicodeRegexParser::UnicodeString.new(97)
|
24
|
-
expect(str.to_regexp_str).to eq"(?:\\
|
24
|
+
expect(str.to_regexp_str).to eq("(?:\\u{0061})")
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -31,34 +31,34 @@ describe UnicodeRegex do
|
|
31
31
|
|
32
32
|
describe "#to_regexp_str" do
|
33
33
|
it "should return the string representation of this regex" do
|
34
|
-
expect(regex.to_regexp_str).to eq("(?:[\\
|
34
|
+
expect(regex.to_regexp_str).to eq("(?:[\\u{0061}-\\u{0063}])")
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
describe "#to_regexp" do
|
39
39
|
it "should return a ruby Regexp" do
|
40
|
-
|
41
|
-
expect(regex.to_regexp).to be_a(Oniguruma::ORegexp)
|
42
|
-
else
|
43
|
-
expect(regex.to_regexp).to be_a(Regexp)
|
44
|
-
end
|
40
|
+
expect(regex.to_regexp).to be_a(Regexp)
|
45
41
|
end
|
46
42
|
|
47
43
|
it "should properly turn various basic regexes into strings" do
|
48
|
-
expect(compile("^abc$").to_regexp_str).to eq("^(?:\\
|
49
|
-
expect(compile("a(b)c").to_regexp_str).to eq("(?:\\
|
50
|
-
expect(compile("a(?:b)c").to_regexp_str).to eq("(?:\\
|
51
|
-
expect(compile("a{1,3}").to_regexp_str).to eq("(?:\\
|
52
|
-
expect(compile("[abc]").to_regexp_str).to eq("(?:[\\
|
44
|
+
expect(compile("^abc$").to_regexp_str).to eq("^(?:\\u{0061})(?:\\u{0062})(?:\\u{0063})$")
|
45
|
+
expect(compile("a(b)c").to_regexp_str).to eq("(?:\\u{0061})((?:\\u{0062}))(?:\\u{0063})")
|
46
|
+
expect(compile("a(?:b)c").to_regexp_str).to eq("(?:\\u{0061})(?:(?:\\u{0062}))(?:\\u{0063})")
|
47
|
+
expect(compile("a{1,3}").to_regexp_str).to eq("(?:\\u{0061}){1,3}")
|
48
|
+
expect(compile("[abc]").to_regexp_str).to eq("(?:[\\u{0061}-\\u{0063}])")
|
53
49
|
end
|
54
50
|
|
55
51
|
it "should properly turn various complex regexes into strings" do
|
56
|
-
expect(compile("[a-z0-9]").to_regexp_str).to eq(
|
57
|
-
|
52
|
+
expect(compile("[a-z0-9]").to_regexp_str).to eq(
|
53
|
+
"(?:[\\u{0030}-\\u{0039}]|[\\u{0061}-\\u{007a}])"
|
54
|
+
)
|
55
|
+
expect(compile("[\\u0067-\\u0071]").to_regexp_str).to eq("(?:[\\u{0067}-\\u{0071}])")
|
58
56
|
end
|
59
57
|
|
60
58
|
it "should properly substitute variables" do
|
61
|
-
expect(compile("$FOO$BAR", symbol_table).to_regexp_str).to eq(
|
59
|
+
expect(compile("$FOO$BAR", symbol_table).to_regexp_str).to eq(
|
60
|
+
"(?:[\\u{0067}-\\u{006b}])(?:[\\u{0070}-\\u{0073}])"
|
61
|
+
)
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -6,19 +6,10 @@
|
|
6
6
|
require 'rspec'
|
7
7
|
require 'rspec/autorun' # somehow makes rcov work with rspec
|
8
8
|
require 'twitter_cldr'
|
9
|
+
require 'pry-nav'
|
10
|
+
require 'coveralls'
|
9
11
|
|
10
|
-
|
11
|
-
if RUBY_ENGINE == "rbx"
|
12
|
-
require 'rubinius/debugger'
|
13
|
-
elsif RUBY_ENGINE == "ruby"
|
14
|
-
require 'pry-nav'
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
if RUBY_VERSION <= "1.8.7"
|
19
|
-
$KCODE = "UTF-8"
|
20
|
-
require 'oniguruma'
|
21
|
-
end
|
12
|
+
Coveralls.wear!
|
22
13
|
|
23
14
|
if ENV['SCOV']
|
24
15
|
require 'simplecov'
|
@@ -32,26 +32,14 @@ require 'yaml'
|
|
32
32
|
# Psych doesn't handle Unicode characters properly, have to use Syck instead.
|
33
33
|
if YAML.const_defined?(:ENGINE)
|
34
34
|
# Fix undefined method `syck_to_yaml' for class `Object' error on MRI 1.9.3.
|
35
|
-
# Target only MRI
|
36
|
-
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ruby' && RUBY_VERSION
|
35
|
+
# Target only MRI ~1.9, because on other Rubies, e.g., JRuby, requiring 'syck' results in a LoadError.
|
36
|
+
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ruby' && RUBY_VERSION < "2.0.0"
|
37
37
|
require 'syck'
|
38
38
|
end
|
39
39
|
|
40
40
|
YAML::ENGINE.yamler = 'syck'
|
41
41
|
end
|
42
42
|
|
43
|
-
# There's an incompatibility in how ruby handles struct dumps
|
44
|
-
# between versions that's beyond our scope.
|
45
|
-
# (One uses strings internally, the other symbols.)
|
46
|
-
# This just enables tests to pass.
|
47
|
-
class << Struct
|
48
|
-
alias yaml_new_without_indifferent_keys yaml_new
|
49
|
-
def yaml_new(klass, tag, val)
|
50
|
-
val.keys.each { |k, v| val[k.to_sym] = val.delete(k) }
|
51
|
-
yaml_new_without_indifferent_keys(klass, tag, val)
|
52
|
-
end
|
53
|
-
end if RUBY_VERSION >= "1.9" && RUBY_VERSION <= "1.9.1" # yaml_new is deprecated in 1.9.2 and later
|
54
|
-
|
55
43
|
STRUCT_KLASS = Struct::new('Foo', :bar, :buz)
|
56
44
|
class Moo
|
57
45
|
attr_accessor :val1, :val2
|
@@ -140,11 +128,9 @@ describe TwitterCldr::Utils do
|
|
140
128
|
end
|
141
129
|
end
|
142
130
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
expect(TwitterCldr::Utils::YAML.dump(h, :preserve_order => true)).to eq("--- \na: 1\nc: 3\nb: 2\n")
|
147
|
-
end
|
131
|
+
it "should preserve hash order" do
|
132
|
+
h = { 'a' => 1, 'c' => 3, 'b' => 2 }
|
133
|
+
expect(TwitterCldr::Utils::YAML.dump(h, :preserve_order => true)).to eq("--- \na: 1\nc: 3\nb: 2\n")
|
148
134
|
end
|
149
135
|
|
150
136
|
it "tests normalization of line breaks" do
|
@@ -430,15 +416,13 @@ describe TwitterCldr::Utils do
|
|
430
416
|
end
|
431
417
|
|
432
418
|
it "tests binary dumps" do
|
433
|
-
|
434
|
-
y = nil
|
419
|
+
y = nil
|
435
420
|
|
436
|
-
|
437
|
-
|
421
|
+
expect { y = TwitterCldr::Utils::YAML.dump('日本語'.force_encoding('ASCII-8BIT')) }.not_to raise_error
|
422
|
+
expect(y).to eq("--- !binary |\n 5pel5pys6Kqe\n\n")
|
438
423
|
|
439
|
-
|
440
|
-
|
441
|
-
end
|
424
|
+
expect { y = TwitterCldr::Utils::YAML.dump('日本語'.encode('EUC-JP').force_encoding('UTF-8')) }.not_to raise_error
|
425
|
+
expect(y).to eq("--- !binary |\n xvzL3Ljs\n\n")
|
442
426
|
end
|
443
427
|
|
444
428
|
end
|
metadata
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twitter_cldr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cameron Dutro
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: camertron-eprun
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: tzinfo
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: cldr-plurals-runtime-rb
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 1.0.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 1.0.0
|
69
69
|
description: Ruby implementation of the ICU (International Components for Unicode)
|
@@ -210,7 +210,6 @@ files:
|
|
210
210
|
- lib/twitter_cldr/tokenizers/unicode_regex/unicode_regex_tokenizer.rb
|
211
211
|
- lib/twitter_cldr/utils.rb
|
212
212
|
- lib/twitter_cldr/utils/code_points.rb
|
213
|
-
- lib/twitter_cldr/utils/interpolation.rb
|
214
213
|
- lib/twitter_cldr/utils/range_set.rb
|
215
214
|
- lib/twitter_cldr/utils/regexp_ast.rb
|
216
215
|
- lib/twitter_cldr/utils/regexp_sampler.rb
|
@@ -1550,7 +1549,6 @@ files:
|
|
1550
1549
|
- spec/tokenizers/unicode_regex/unicode_regex_tokenizer_spec.rb
|
1551
1550
|
- spec/twitter_cldr_spec.rb
|
1552
1551
|
- spec/utils/code_points_spec.rb
|
1553
|
-
- spec/utils/interpolation_spec.rb
|
1554
1552
|
- spec/utils/range_set_spec.rb
|
1555
1553
|
- spec/utils/regexp_ast_spec.rb
|
1556
1554
|
- spec/utils/regexp_sampler_spec.rb
|
@@ -1568,19 +1566,20 @@ require_paths:
|
|
1568
1566
|
- lib
|
1569
1567
|
required_ruby_version: !ruby/object:Gem::Requirement
|
1570
1568
|
requirements:
|
1571
|
-
- -
|
1569
|
+
- - ">="
|
1572
1570
|
- !ruby/object:Gem::Version
|
1573
1571
|
version: '0'
|
1574
1572
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1575
1573
|
requirements:
|
1576
|
-
- -
|
1574
|
+
- - ">="
|
1577
1575
|
- !ruby/object:Gem::Version
|
1578
1576
|
version: '0'
|
1579
1577
|
requirements: []
|
1580
1578
|
rubyforge_project:
|
1581
|
-
rubygems_version: 2.2.
|
1579
|
+
rubygems_version: 2.2.2
|
1582
1580
|
signing_key:
|
1583
1581
|
specification_version: 4
|
1584
1582
|
summary: Ruby implementation of the ICU (International Components for Unicode) that
|
1585
1583
|
uses the Common Locale Data Repository to format dates, plurals, and more.
|
1586
1584
|
test_files: []
|
1585
|
+
has_rdoc: true
|
@@ -1,105 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
# Copyright 2012 Twitter, Inc
|
4
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
5
|
-
|
6
|
-
# The implementation of the TwitterCldr.interpolate method that backports String interpolation capabilities
|
7
|
-
# (originally implemented in String#% method) from Ruby 1.9 to Ruby 1.8 is heavily influenced by the
|
8
|
-
# implementation of the same feature in i18n (https://github.com/svenfuchs/i18n/blob/89ea337f48562370988421e50caa7c2fe89452c7/lib/i18n/core_ext/string/interpolate.rb)
|
9
|
-
# and gettext (https://github.com/mutoh/gettext/blob/11b8c1525ba9f00afb1942f7ebf34bec12f7558b/lib/gettext/core_ext/string.rb) gems.
|
10
|
-
#
|
11
|
-
# See NOTICE file for corresponding license agreements.
|
12
|
-
|
13
|
-
|
14
|
-
# KeyError is raised during interpolation when there is a placeholder that doesn't have corresponding key in the
|
15
|
-
# interpolation hash. KeyError is defined in 1.9. We define it for prior versions of Ruby to have the same behavior.
|
16
|
-
#
|
17
|
-
class KeyError < IndexError
|
18
|
-
def initialize(message = nil)
|
19
|
-
super(message || 'key not found')
|
20
|
-
end
|
21
|
-
end unless defined?(KeyError)
|
22
|
-
|
23
|
-
|
24
|
-
module TwitterCldr
|
25
|
-
module Utils
|
26
|
-
|
27
|
-
HASH_INTERPOLATION_REGEXP = Regexp.union(
|
28
|
-
/%\{(\w+)\}/,
|
29
|
-
/%<(\w+)>(.*?\d*\.?\d*[bBdiouxXeEfgGcps])/
|
30
|
-
)
|
31
|
-
|
32
|
-
HASH_INTERPOLATION_WITH_ESCAPE_REGEXP = Regexp.union(
|
33
|
-
/%%/,
|
34
|
-
HASH_INTERPOLATION_REGEXP
|
35
|
-
)
|
36
|
-
|
37
|
-
class << self
|
38
|
-
|
39
|
-
# Uses +string+ as a format specification and returns the result of applying it to +args+.
|
40
|
-
#
|
41
|
-
# There are three ways to use it:
|
42
|
-
#
|
43
|
-
# * Using a single argument or Array of arguments.
|
44
|
-
#
|
45
|
-
# This is the default behaviour of the String#% method. See Kernel#sprintf for more details about the format
|
46
|
-
# specification.
|
47
|
-
#
|
48
|
-
# Example:
|
49
|
-
#
|
50
|
-
# TwitterCldr::Utils.interpolate('%d %s', [1, 'message'])
|
51
|
-
# # => "1 message"
|
52
|
-
#
|
53
|
-
# * Using a Hash as an argument and unformatted, named placeholders (Ruby 1.9 syntax).
|
54
|
-
#
|
55
|
-
# When you pass a Hash as an argument and specify placeholders with %{foo} it will interpret the hash values as
|
56
|
-
# named arguments.
|
57
|
-
#
|
58
|
-
# Example:
|
59
|
-
#
|
60
|
-
# TwitterCldr::Utils.interpolate('%{firstname}, %{lastname}', :firstname => 'Masao', :lastname => 'Mutoh')
|
61
|
-
# # => "Masao Mutoh"
|
62
|
-
#
|
63
|
-
# * Using a Hash as an argument and formatted, named placeholders (Ruby 1.9 syntax).
|
64
|
-
#
|
65
|
-
# When you pass a Hash as an argument and specify placeholders with %<foo>d it will interpret the hash values
|
66
|
-
# as named arguments and format the value according to the formatting instruction appended to the closing >.
|
67
|
-
#
|
68
|
-
# Example:
|
69
|
-
#
|
70
|
-
# TwitterCldr::Utils.interpolate('%<integer>d, %<float>.1f', :integer => 10, :float => 43.4)
|
71
|
-
# # => "10, 43.3"
|
72
|
-
#
|
73
|
-
# An exception can be thrown in two cases when Ruby 1.9 interpolation syntax is used:
|
74
|
-
#
|
75
|
-
# * ArgumentError is thrown if Ruby 1.9. interpolation syntax is used in +string+, but +args+ is not a Hash;
|
76
|
-
# * KeyError is thrown if the value for one of the placeholders in +string+ is missing in +args+ hash.
|
77
|
-
#
|
78
|
-
def interpolate(string, args)
|
79
|
-
string =~ HASH_INTERPOLATION_REGEXP ? interpolate_hash(string, args) : interpolate_value_or_array(string, args)
|
80
|
-
end
|
81
|
-
|
82
|
-
private
|
83
|
-
|
84
|
-
def interpolate_hash(string, args)
|
85
|
-
raise ArgumentError.new('expected a Hash') unless args.is_a?(Hash)
|
86
|
-
|
87
|
-
string.gsub(HASH_INTERPOLATION_WITH_ESCAPE_REGEXP) do |match|
|
88
|
-
if match == '%%'
|
89
|
-
'%'
|
90
|
-
else
|
91
|
-
key = ($1 || $2).to_sym
|
92
|
-
raise KeyError unless args.has_key?(key)
|
93
|
-
$3 ? sprintf("%#{$3}", args[key]) : args[key]
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
def interpolate_value_or_array(string, args)
|
99
|
-
string.gsub(/%([{<])/, '%%\1') % args
|
100
|
-
end
|
101
|
-
|
102
|
-
end
|
103
|
-
|
104
|
-
end
|
105
|
-
end
|