twitter_cldr 3.0.0.beta1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +16 -2
- data/History.txt +9 -1
- data/README.md +297 -113
- data/Rakefile +97 -17
- data/lib/twitter_cldr/collation/collator.rb +12 -3
- data/lib/twitter_cldr/collation/trie_builder.rb +1 -1
- data/lib/twitter_cldr/{tokenizers/calendars → data_readers}/additional_date_format_selector.rb +6 -4
- data/lib/twitter_cldr/data_readers/calendar_data_reader.rb +91 -0
- data/lib/twitter_cldr/data_readers/data_reader.rb +32 -0
- data/lib/twitter_cldr/data_readers/date_data_reader.rb +26 -0
- data/lib/twitter_cldr/data_readers/date_time_data_reader.rb +41 -0
- data/lib/twitter_cldr/data_readers/number_data_reader.rb +142 -0
- data/lib/twitter_cldr/data_readers/time_data_reader.rb +26 -0
- data/lib/twitter_cldr/data_readers/timespan_data_reader.rb +122 -0
- data/lib/twitter_cldr/data_readers.rb +17 -0
- data/lib/twitter_cldr/formatters/calendars/{datetime_formatter.rb → date_time_formatter.rb} +27 -42
- data/lib/twitter_cldr/formatters/calendars/timespan_formatter.rb +3 -64
- data/lib/twitter_cldr/formatters/formatter.rb +39 -0
- data/lib/twitter_cldr/formatters/list_formatter.rb +22 -12
- data/lib/twitter_cldr/formatters/numbers/abbreviated/abbreviated_number_formatter.rb +5 -26
- data/lib/twitter_cldr/formatters/numbers/currency_formatter.rb +2 -11
- data/lib/twitter_cldr/formatters/numbers/decimal_formatter.rb +4 -2
- data/lib/twitter_cldr/formatters/numbers/number_formatter.rb +45 -27
- data/lib/twitter_cldr/formatters/numbers/percent_formatter.rb +3 -13
- data/lib/twitter_cldr/formatters/numbers/rbnf/formatters.rb +224 -0
- data/lib/twitter_cldr/formatters/numbers/rbnf/post_processors/chinese.rb +122 -0
- data/lib/twitter_cldr/formatters/numbers/rbnf/rule.rb +93 -0
- data/lib/twitter_cldr/formatters/numbers/rbnf/rule_group.rb +20 -0
- data/lib/twitter_cldr/formatters/numbers/rbnf/rule_parser.rb +86 -0
- data/lib/twitter_cldr/formatters/numbers/rbnf/rule_set.rb +259 -0
- data/lib/twitter_cldr/formatters/numbers/rbnf/substitution.rb +30 -0
- data/lib/twitter_cldr/formatters/numbers/rbnf.rb +127 -0
- data/lib/twitter_cldr/formatters/plurals/plural_formatter.rb +18 -6
- data/lib/twitter_cldr/formatters.rb +4 -5
- data/lib/twitter_cldr/localized/localized_array.rb +1 -1
- data/lib/twitter_cldr/localized/localized_date.rb +6 -3
- data/lib/twitter_cldr/localized/localized_datetime.rb +38 -15
- data/lib/twitter_cldr/localized/localized_number.rb +40 -24
- data/lib/twitter_cldr/localized/localized_object.rb +4 -4
- data/lib/twitter_cldr/localized/localized_string.rb +40 -7
- data/lib/twitter_cldr/localized/localized_time.rb +9 -2
- data/lib/twitter_cldr/localized/localized_timespan.rb +50 -5
- data/lib/twitter_cldr/normalization.rb +8 -19
- data/lib/twitter_cldr/parsers/parser.rb +50 -0
- data/lib/twitter_cldr/parsers/segmentation_parser.rb +137 -0
- data/lib/twitter_cldr/parsers/symbol_table.rb +30 -0
- data/lib/twitter_cldr/parsers/unicode_regex/character_class.rb +91 -0
- data/lib/twitter_cldr/parsers/unicode_regex/character_range.rb +39 -0
- data/lib/twitter_cldr/parsers/unicode_regex/character_set.rb +65 -0
- data/lib/twitter_cldr/parsers/unicode_regex/component.rb +50 -0
- data/lib/twitter_cldr/parsers/unicode_regex/literal.rb +83 -0
- data/lib/twitter_cldr/parsers/unicode_regex/unicode_string.rb +41 -0
- data/lib/twitter_cldr/parsers/unicode_regex_parser.rb +262 -0
- data/lib/twitter_cldr/parsers.rb +5 -1
- data/lib/twitter_cldr/resources/casefolder.rb.erb +64 -0
- data/lib/twitter_cldr/resources/casefolder_class_generator.rb +75 -0
- data/lib/twitter_cldr/resources/download.rb +10 -4
- data/lib/twitter_cldr/resources/icu_based_importer.rb +18 -0
- data/lib/twitter_cldr/resources/locales_resources_importer.rb +24 -13
- data/lib/twitter_cldr/resources/normalization_quick_check_importer.rb +1 -14
- data/lib/twitter_cldr/resources/rbnf_test_importer.rb +107 -0
- data/lib/twitter_cldr/resources/readme_renderer.rb +115 -0
- data/lib/twitter_cldr/resources/tailoring_importer.rb +2 -8
- data/lib/twitter_cldr/resources/uli/segment_exceptions_importer.rb +62 -0
- data/lib/twitter_cldr/resources/uli.rb +12 -0
- data/lib/twitter_cldr/resources/unicode_data_importer.rb +84 -14
- data/lib/twitter_cldr/resources/unicode_importer.rb +37 -0
- data/lib/twitter_cldr/resources/unicode_properties_importer.rb +79 -0
- data/lib/twitter_cldr/resources.rb +8 -1
- data/lib/twitter_cldr/shared/break_iterator.rb +213 -0
- data/lib/twitter_cldr/shared/calendar.rb +38 -14
- data/lib/twitter_cldr/shared/casefolder.rb +210 -0
- data/lib/twitter_cldr/shared/code_point.rb +103 -16
- data/lib/twitter_cldr/shared/numbering_system.rb +58 -0
- data/lib/twitter_cldr/shared/territories.rb +43 -1
- data/lib/twitter_cldr/shared/unicode_regex.rb +81 -0
- data/lib/twitter_cldr/shared.rb +13 -9
- data/lib/twitter_cldr/tokenizers/calendars/date_time_tokenizer.rb +77 -0
- data/lib/twitter_cldr/tokenizers/calendars/date_tokenizer.rb +14 -29
- data/lib/twitter_cldr/tokenizers/calendars/time_tokenizer.rb +13 -28
- data/lib/twitter_cldr/tokenizers/calendars/timespan_tokenizer.rb +11 -87
- data/lib/twitter_cldr/tokenizers/numbers/number_tokenizer.rb +16 -71
- data/lib/twitter_cldr/tokenizers/numbers/rbnf_tokenizer.rb +53 -0
- data/lib/twitter_cldr/tokenizers/pattern_tokenizer.rb +42 -0
- data/lib/twitter_cldr/tokenizers/segmentation/segmentation_tokenizer.rb +39 -0
- data/lib/twitter_cldr/tokenizers/tokenizer.rb +116 -0
- data/lib/twitter_cldr/tokenizers/unicode_regex/unicode_regex_tokenizer.rb +52 -0
- data/lib/twitter_cldr/tokenizers.rb +8 -4
- data/lib/twitter_cldr/utils/code_points.rb +1 -1
- data/lib/twitter_cldr/utils/range_set.rb +242 -0
- data/lib/twitter_cldr/utils/yaml.rb +17 -12
- data/lib/twitter_cldr/utils.rb +1 -1
- data/lib/twitter_cldr/version.rb +1 -1
- data/lib/twitter_cldr.rb +2 -1
- data/resources/custom/locales/sv/units.yml +8 -0
- data/resources/locales/af/calendars.yml +278 -224
- data/resources/locales/af/currencies.yml +954 -916
- data/resources/locales/af/languages.yml +583 -580
- data/resources/locales/af/layout.yml +5 -5
- data/resources/locales/af/lists.yml +23 -7
- data/resources/locales/af/numbers.yml +59 -54
- data/resources/locales/af/plurals.yml +2 -2
- data/resources/locales/af/rbnf.yml +261 -0
- data/resources/locales/af/territories.yml +264 -263
- data/resources/locales/ar/calendars.yml +287 -259
- data/resources/locales/ar/currencies.yml +1730 -1692
- data/resources/locales/ar/languages.yml +583 -580
- data/resources/locales/ar/layout.yml +5 -5
- data/resources/locales/ar/lists.yml +23 -7
- data/resources/locales/ar/numbers.yml +66 -61
- data/resources/locales/ar/plurals.yml +5 -8
- data/resources/locales/ar/rbnf.yml +519 -0
- data/resources/locales/ar/territories.yml +264 -263
- data/resources/locales/be/calendars.yml +238 -237
- data/resources/locales/be/currencies.yml +954 -917
- data/resources/locales/be/languages.yml +583 -580
- data/resources/locales/be/layout.yml +5 -5
- data/resources/locales/be/lists.yml +23 -7
- data/resources/locales/be/numbers.yml +62 -57
- data/resources/locales/be/plurals.yml +7 -4
- data/resources/locales/be/rbnf.yml +1288 -0
- data/resources/locales/be/territories.yml +264 -263
- data/resources/locales/bg/calendars.yml +278 -218
- data/resources/locales/bg/currencies.yml +955 -917
- data/resources/locales/bg/languages.yml +583 -580
- data/resources/locales/bg/layout.yml +5 -5
- data/resources/locales/bg/lists.yml +23 -7
- data/resources/locales/bg/numbers.yml +62 -57
- data/resources/locales/bg/plurals.yml +2 -2
- data/resources/locales/bg/rbnf.yml +280 -0
- data/resources/locales/bg/territories.yml +264 -263
- data/resources/locales/bn/calendars.yml +287 -225
- data/resources/locales/bn/currencies.yml +953 -916
- data/resources/locales/bn/languages.yml +583 -580
- data/resources/locales/bn/layout.yml +5 -5
- data/resources/locales/bn/lists.yml +23 -7
- data/resources/locales/bn/numbers.yml +62 -57
- data/resources/locales/bn/plurals.yml +2 -2
- data/resources/locales/bn/rbnf.yml +4 -0
- data/resources/locales/bn/territories.yml +264 -263
- data/resources/locales/ca/calendars.yml +278 -278
- data/resources/locales/ca/currencies.yml +953 -916
- data/resources/locales/ca/languages.yml +583 -580
- data/resources/locales/ca/layout.yml +5 -5
- data/resources/locales/ca/lists.yml +23 -7
- data/resources/locales/ca/numbers.yml +62 -57
- data/resources/locales/ca/plurals.yml +3 -2
- data/resources/locales/ca/rbnf.yml +756 -0
- data/resources/locales/ca/territories.yml +264 -263
- data/resources/locales/cs/calendars.yml +269 -262
- data/resources/locales/cs/currencies.yml +1483 -1172
- data/resources/locales/cs/languages.yml +583 -580
- data/resources/locales/cs/layout.yml +5 -5
- data/resources/locales/cs/lists.yml +23 -7
- data/resources/locales/cs/numbers.yml +64 -58
- data/resources/locales/cs/plurals.yml +6 -2
- data/resources/locales/cs/rbnf.yml +367 -0
- data/resources/locales/cs/territories.yml +264 -263
- data/resources/locales/cy/calendars.yml +275 -274
- data/resources/locales/cy/currencies.yml +1585 -1548
- data/resources/locales/cy/languages.yml +583 -580
- data/resources/locales/cy/layout.yml +5 -5
- data/resources/locales/cy/lists.yml +23 -7
- data/resources/locales/cy/numbers.yml +66 -61
- data/resources/locales/cy/plurals.yml +4 -3
- data/resources/locales/cy/rbnf.yml +298 -0
- data/resources/locales/cy/territories.yml +264 -263
- data/resources/locales/da/calendars.yml +281 -280
- data/resources/locales/da/currencies.yml +954 -916
- data/resources/locales/da/languages.yml +583 -580
- data/resources/locales/da/layout.yml +5 -5
- data/resources/locales/da/lists.yml +23 -7
- data/resources/locales/da/numbers.yml +62 -57
- data/resources/locales/da/plurals.yml +3 -2
- data/resources/locales/da/rbnf.yml +194 -0
- data/resources/locales/da/territories.yml +264 -263
- data/resources/locales/de/calendars.yml +294 -293
- data/resources/locales/de/currencies.yml +954 -916
- data/resources/locales/de/languages.yml +583 -580
- data/resources/locales/de/layout.yml +5 -5
- data/resources/locales/de/lists.yml +23 -7
- data/resources/locales/de/numbers.yml +62 -57
- data/resources/locales/de/plurals.yml +3 -2
- data/resources/locales/de/rbnf.yml +346 -0
- data/resources/locales/de/territories.yml +264 -263
- data/resources/locales/el/calendars.yml +279 -282
- data/resources/locales/el/currencies.yml +954 -916
- data/resources/locales/el/languages.yml +583 -580
- data/resources/locales/el/layout.yml +5 -5
- data/resources/locales/el/lists.yml +23 -7
- data/resources/locales/el/numbers.yml +62 -57
- data/resources/locales/el/plurals.yml +2 -2
- data/resources/locales/el/rbnf.yml +880 -0
- data/resources/locales/el/territories.yml +264 -263
- data/resources/locales/en/calendars.yml +192 -191
- data/resources/locales/en/currencies.yml +953 -915
- data/resources/locales/en/languages.yml +583 -580
- data/resources/locales/en/layout.yml +5 -5
- data/resources/locales/en/lists.yml +23 -7
- data/resources/locales/en/numbers.yml +62 -57
- data/resources/locales/en/plurals.yml +3 -2
- data/resources/locales/en/rbnf.yml +542 -0
- data/resources/locales/en/territories.yml +264 -263
- data/resources/locales/en-GB/calendars.yml +195 -194
- data/resources/locales/en-GB/currencies.yml +953 -915
- data/resources/locales/en-GB/languages.yml +583 -580
- data/resources/locales/en-GB/layout.yml +5 -5
- data/resources/locales/en-GB/lists.yml +23 -7
- data/resources/locales/en-GB/numbers.yml +62 -57
- data/resources/locales/en-GB/plurals.yml +2 -1
- data/resources/locales/en-GB/rbnf.yml +4 -0
- data/resources/locales/en-GB/territories.yml +264 -263
- data/resources/locales/es/calendars.yml +288 -238
- data/resources/locales/es/currencies.yml +953 -922
- data/resources/locales/es/languages.yml +583 -580
- data/resources/locales/es/layout.yml +5 -5
- data/resources/locales/es/lists.yml +23 -7
- data/resources/locales/es/numbers.yml +62 -57
- data/resources/locales/es/plurals.yml +2 -2
- data/resources/locales/es/rbnf.yml +913 -0
- data/resources/locales/es/territories.yml +264 -263
- data/resources/locales/eu/calendars.yml +277 -218
- data/resources/locales/eu/currencies.yml +953 -916
- data/resources/locales/eu/languages.yml +583 -580
- data/resources/locales/eu/layout.yml +5 -5
- data/resources/locales/eu/lists.yml +23 -7
- data/resources/locales/eu/numbers.yml +56 -51
- data/resources/locales/eu/plurals.yml +2 -2
- data/resources/locales/eu/rbnf.yml +4 -0
- data/resources/locales/eu/territories.yml +264 -263
- data/resources/locales/fa/calendars.yml +294 -293
- data/resources/locales/fa/currencies.yml +955 -916
- data/resources/locales/fa/languages.yml +583 -580
- data/resources/locales/fa/layout.yml +5 -5
- data/resources/locales/fa/lists.yml +23 -7
- data/resources/locales/fa/numbers.yml +62 -57
- data/resources/locales/fa/plurals.yml +2 -2
- data/resources/locales/fa/rbnf.yml +157 -0
- data/resources/locales/fa/territories.yml +264 -263
- data/resources/locales/fi/calendars.yml +284 -283
- data/resources/locales/fi/currencies.yml +953 -915
- data/resources/locales/fi/languages.yml +583 -580
- data/resources/locales/fi/layout.yml +5 -5
- data/resources/locales/fi/lists.yml +23 -7
- data/resources/locales/fi/numbers.yml +62 -57
- data/resources/locales/fi/plurals.yml +3 -2
- data/resources/locales/fi/rbnf.yml +206 -0
- data/resources/locales/fi/territories.yml +264 -263
- data/resources/locales/fil/calendars.yml +281 -230
- data/resources/locales/fil/currencies.yml +953 -916
- data/resources/locales/fil/languages.yml +583 -580
- data/resources/locales/fil/layout.yml +5 -5
- data/resources/locales/fil/lists.yml +23 -7
- data/resources/locales/fil/numbers.yml +62 -57
- data/resources/locales/fil/plurals.yml +3 -2
- data/resources/locales/fil/rbnf.yml +158 -0
- data/resources/locales/fil/territories.yml +264 -263
- data/resources/locales/fr/calendars.yml +297 -296
- data/resources/locales/fr/currencies.yml +968 -949
- data/resources/locales/fr/languages.yml +583 -580
- data/resources/locales/fr/layout.yml +5 -5
- data/resources/locales/fr/lists.yml +23 -7
- data/resources/locales/fr/numbers.yml +62 -57
- data/resources/locales/fr/plurals.yml +2 -2
- data/resources/locales/fr/rbnf.yml +621 -0
- data/resources/locales/fr/territories.yml +264 -263
- data/resources/locales/ga/calendars.yml +192 -191
- data/resources/locales/ga/currencies.yml +954 -916
- data/resources/locales/ga/languages.yml +583 -580
- data/resources/locales/ga/layout.yml +5 -5
- data/resources/locales/ga/lists.yml +23 -7
- data/resources/locales/ga/numbers.yml +62 -57
- data/resources/locales/ga/plurals.yml +4 -3
- data/resources/locales/ga/rbnf.yml +615 -0
- data/resources/locales/ga/territories.yml +264 -263
- data/resources/locales/gl/calendars.yml +283 -217
- data/resources/locales/gl/currencies.yml +953 -916
- data/resources/locales/gl/languages.yml +583 -580
- data/resources/locales/gl/layout.yml +5 -5
- data/resources/locales/gl/lists.yml +23 -7
- data/resources/locales/gl/numbers.yml +62 -57
- data/resources/locales/gl/plurals.yml +3 -2
- data/resources/locales/gl/rbnf.yml +4 -0
- data/resources/locales/gl/territories.yml +264 -263
- data/resources/locales/he/calendars.yml +248 -220
- data/resources/locales/he/currencies.yml +992 -932
- data/resources/locales/he/languages.yml +583 -580
- data/resources/locales/he/layout.yml +5 -5
- data/resources/locales/he/lists.yml +23 -7
- data/resources/locales/he/numbers.yml +64 -59
- data/resources/locales/he/plurals.yml +6 -3
- data/resources/locales/he/rbnf.yml +1029 -0
- data/resources/locales/he/territories.yml +264 -263
- data/resources/locales/hi/calendars.yml +284 -216
- data/resources/locales/hi/currencies.yml +953 -915
- data/resources/locales/hi/languages.yml +583 -580
- data/resources/locales/hi/layout.yml +5 -5
- data/resources/locales/hi/lists.yml +23 -7
- data/resources/locales/hi/numbers.yml +60 -55
- data/resources/locales/hi/plurals.yml +2 -2
- data/resources/locales/hi/rbnf.yml +430 -0
- data/resources/locales/hi/territories.yml +264 -263
- data/resources/locales/hr/calendars.yml +308 -307
- data/resources/locales/hr/currencies.yml +1248 -1504
- data/resources/locales/hr/languages.yml +583 -580
- data/resources/locales/hr/layout.yml +5 -5
- data/resources/locales/hr/lists.yml +23 -7
- data/resources/locales/hr/numbers.yml +63 -59
- data/resources/locales/hr/plurals.yml +12 -4
- data/resources/locales/hr/rbnf.yml +599 -0
- data/resources/locales/hr/territories.yml +264 -263
- data/resources/locales/hu/calendars.yml +285 -284
- data/resources/locales/hu/currencies.yml +954 -916
- data/resources/locales/hu/languages.yml +583 -580
- data/resources/locales/hu/layout.yml +5 -5
- data/resources/locales/hu/lists.yml +23 -7
- data/resources/locales/hu/numbers.yml +62 -57
- data/resources/locales/hu/plurals.yml +2 -2
- data/resources/locales/hu/rbnf.yml +363 -0
- data/resources/locales/hu/territories.yml +264 -263
- data/resources/locales/id/calendars.yml +276 -275
- data/resources/locales/id/currencies.yml +954 -916
- data/resources/locales/id/languages.yml +583 -580
- data/resources/locales/id/layout.yml +5 -5
- data/resources/locales/id/lists.yml +23 -7
- data/resources/locales/id/numbers.yml +61 -56
- data/resources/locales/id/plurals.yml +2 -2
- data/resources/locales/id/rbnf.yml +121 -0
- data/resources/locales/id/territories.yml +264 -263
- data/resources/locales/is/calendars.yml +281 -242
- data/resources/locales/is/currencies.yml +954 -916
- data/resources/locales/is/languages.yml +583 -580
- data/resources/locales/is/layout.yml +5 -5
- data/resources/locales/is/lists.yml +23 -7
- data/resources/locales/is/numbers.yml +62 -57
- data/resources/locales/is/plurals.yml +5 -2
- data/resources/locales/is/rbnf.yml +326 -0
- data/resources/locales/is/territories.yml +264 -263
- data/resources/locales/it/calendars.yml +275 -260
- data/resources/locales/it/currencies.yml +953 -920
- data/resources/locales/it/languages.yml +583 -580
- data/resources/locales/it/layout.yml +5 -5
- data/resources/locales/it/lists.yml +23 -7
- data/resources/locales/it/numbers.yml +59 -54
- data/resources/locales/it/plurals.yml +3 -2
- data/resources/locales/it/rbnf.yml +1189 -0
- data/resources/locales/it/territories.yml +264 -263
- data/resources/locales/ja/calendars.yml +269 -207
- data/resources/locales/ja/currencies.yml +953 -915
- data/resources/locales/ja/languages.yml +583 -580
- data/resources/locales/ja/layout.yml +5 -5
- data/resources/locales/ja/lists.yml +23 -7
- data/resources/locales/ja/numbers.yml +62 -57
- data/resources/locales/ja/plurals.yml +2 -2
- data/resources/locales/ja/rbnf.yml +209 -0
- data/resources/locales/ja/territories.yml +264 -263
- data/resources/locales/ko/calendars.yml +246 -213
- data/resources/locales/ko/currencies.yml +953 -915
- data/resources/locales/ko/languages.yml +583 -580
- data/resources/locales/ko/layout.yml +5 -5
- data/resources/locales/ko/lists.yml +23 -7
- data/resources/locales/ko/numbers.yml +60 -55
- data/resources/locales/ko/plurals.yml +2 -2
- data/resources/locales/ko/rbnf.yml +722 -0
- data/resources/locales/ko/territories.yml +264 -263
- data/resources/locales/lv/calendars.yml +286 -285
- data/resources/locales/lv/currencies.yml +1122 -1084
- data/resources/locales/lv/languages.yml +583 -580
- data/resources/locales/lv/layout.yml +5 -5
- data/resources/locales/lv/lists.yml +23 -7
- data/resources/locales/lv/numbers.yml +63 -58
- data/resources/locales/lv/plurals.yml +11 -3
- data/resources/locales/lv/rbnf.yml +238 -0
- data/resources/locales/lv/territories.yml +264 -263
- data/resources/locales/ms/calendars.yml +280 -279
- data/resources/locales/ms/currencies.yml +954 -916
- data/resources/locales/ms/languages.yml +583 -580
- data/resources/locales/ms/layout.yml +5 -5
- data/resources/locales/ms/lists.yml +23 -7
- data/resources/locales/ms/numbers.yml +62 -57
- data/resources/locales/ms/plurals.yml +2 -2
- data/resources/locales/ms/rbnf.yml +130 -0
- data/resources/locales/ms/territories.yml +264 -263
- data/resources/locales/nb/calendars.yml +284 -283
- data/resources/locales/nb/currencies.yml +958 -916
- data/resources/locales/nb/languages.yml +583 -580
- data/resources/locales/nb/layout.yml +5 -5
- data/resources/locales/nb/lists.yml +23 -7
- data/resources/locales/nb/numbers.yml +62 -57
- data/resources/locales/nb/plurals.yml +2 -2
- data/resources/locales/nb/rbnf.yml +191 -0
- data/resources/locales/nb/territories.yml +264 -263
- data/resources/locales/nl/calendars.yml +285 -284
- data/resources/locales/nl/currencies.yml +953 -917
- data/resources/locales/nl/languages.yml +583 -580
- data/resources/locales/nl/layout.yml +5 -5
- data/resources/locales/nl/lists.yml +23 -7
- data/resources/locales/nl/numbers.yml +62 -57
- data/resources/locales/nl/plurals.yml +3 -2
- data/resources/locales/nl/rbnf.yml +320 -0
- data/resources/locales/nl/territories.yml +264 -263
- data/resources/locales/pl/calendars.yml +288 -287
- data/resources/locales/pl/currencies.yml +1326 -1284
- data/resources/locales/pl/languages.yml +583 -580
- data/resources/locales/pl/layout.yml +5 -5
- data/resources/locales/pl/lists.yml +23 -7
- data/resources/locales/pl/numbers.yml +64 -59
- data/resources/locales/pl/plurals.yml +11 -4
- data/resources/locales/pl/rbnf.yml +410 -0
- data/resources/locales/pl/territories.yml +264 -263
- data/resources/locales/pt/calendars.yml +290 -289
- data/resources/locales/pt/currencies.yml +954 -916
- data/resources/locales/pt/languages.yml +583 -580
- data/resources/locales/pt/layout.yml +5 -5
- data/resources/locales/pt/lists.yml +23 -7
- data/resources/locales/pt/numbers.yml +62 -57
- data/resources/locales/pt/plurals.yml +4 -2
- data/resources/locales/pt/rbnf.yml +586 -0
- data/resources/locales/pt/territories.yml +264 -263
- data/resources/locales/ro/calendars.yml +284 -283
- data/resources/locales/ro/currencies.yml +1170 -1132
- data/resources/locales/ro/languages.yml +583 -580
- data/resources/locales/ro/layout.yml +5 -5
- data/resources/locales/ro/lists.yml +23 -7
- data/resources/locales/ro/numbers.yml +63 -58
- data/resources/locales/ro/plurals.yml +5 -2
- data/resources/locales/ro/rbnf.yml +250 -0
- data/resources/locales/ro/territories.yml +264 -263
- data/resources/locales/ru/calendars.yml +282 -281
- data/resources/locales/ru/currencies.yml +1118 -1247
- data/resources/locales/ru/languages.yml +583 -580
- data/resources/locales/ru/layout.yml +5 -5
- data/resources/locales/ru/lists.yml +23 -7
- data/resources/locales/ru/numbers.yml +63 -59
- data/resources/locales/ru/plurals.yml +8 -4
- data/resources/locales/ru/rbnf.yml +385 -0
- data/resources/locales/ru/territories.yml +264 -263
- data/resources/locales/sk/calendars.yml +254 -251
- data/resources/locales/sk/currencies.yml +1174 -1008
- data/resources/locales/sk/languages.yml +583 -580
- data/resources/locales/sk/layout.yml +5 -5
- data/resources/locales/sk/lists.yml +23 -7
- data/resources/locales/sk/numbers.yml +64 -58
- data/resources/locales/sk/plurals.yml +6 -2
- data/resources/locales/sk/rbnf.yml +304 -0
- data/resources/locales/sk/territories.yml +264 -263
- data/resources/locales/sq/calendars.yml +283 -206
- data/resources/locales/sq/currencies.yml +954 -916
- data/resources/locales/sq/languages.yml +583 -580
- data/resources/locales/sq/layout.yml +5 -5
- data/resources/locales/sq/lists.yml +23 -7
- data/resources/locales/sq/numbers.yml +62 -57
- data/resources/locales/sq/plurals.yml +2 -2
- data/resources/locales/sq/rbnf.yml +181 -0
- data/resources/locales/sq/territories.yml +264 -263
- data/resources/locales/sr/calendars.yml +290 -289
- data/resources/locales/sr/currencies.yml +1251 -1508
- data/resources/locales/sr/languages.yml +583 -580
- data/resources/locales/sr/layout.yml +5 -5
- data/resources/locales/sr/lists.yml +23 -7
- data/resources/locales/sr/numbers.yml +62 -58
- data/resources/locales/sr/plurals.yml +12 -4
- data/resources/locales/sr/rbnf.yml +429 -0
- data/resources/locales/sr/territories.yml +264 -263
- data/resources/locales/sv/calendars.yml +290 -289
- data/resources/locales/sv/currencies.yml +960 -930
- data/resources/locales/sv/languages.yml +583 -580
- data/resources/locales/sv/layout.yml +5 -5
- data/resources/locales/sv/lists.yml +23 -7
- data/resources/locales/sv/numbers.yml +63 -58
- data/resources/locales/sv/plurals.yml +3 -2
- data/resources/locales/sv/rbnf.yml +692 -0
- data/resources/locales/sv/territories.yml +264 -263
- data/resources/locales/ta/calendars.yml +281 -266
- data/resources/locales/ta/currencies.yml +953 -915
- data/resources/locales/ta/languages.yml +583 -580
- data/resources/locales/ta/layout.yml +5 -5
- data/resources/locales/ta/lists.yml +23 -7
- data/resources/locales/ta/numbers.yml +62 -57
- data/resources/locales/ta/plurals.yml +2 -2
- data/resources/locales/ta/rbnf.yml +241 -0
- data/resources/locales/ta/territories.yml +264 -263
- data/resources/locales/th/calendars.yml +278 -289
- data/resources/locales/th/currencies.yml +953 -915
- data/resources/locales/th/languages.yml +583 -580
- data/resources/locales/th/layout.yml +5 -5
- data/resources/locales/th/lists.yml +23 -7
- data/resources/locales/th/numbers.yml +62 -57
- data/resources/locales/th/plurals.yml +2 -2
- data/resources/locales/th/rbnf.yml +119 -0
- data/resources/locales/th/territories.yml +264 -263
- data/resources/locales/tr/calendars.yml +287 -286
- data/resources/locales/tr/currencies.yml +953 -916
- data/resources/locales/tr/languages.yml +583 -580
- data/resources/locales/tr/layout.yml +5 -5
- data/resources/locales/tr/lists.yml +23 -7
- data/resources/locales/tr/numbers.yml +61 -56
- data/resources/locales/tr/plurals.yml +2 -2
- data/resources/locales/tr/rbnf.yml +277 -0
- data/resources/locales/tr/territories.yml +264 -263
- data/resources/locales/uk/calendars.yml +286 -252
- data/resources/locales/uk/currencies.yml +1311 -1070
- data/resources/locales/uk/languages.yml +583 -580
- data/resources/locales/uk/layout.yml +5 -5
- data/resources/locales/uk/lists.yml +23 -7
- data/resources/locales/uk/numbers.yml +64 -59
- data/resources/locales/uk/plurals.yml +10 -4
- data/resources/locales/uk/rbnf.yml +430 -0
- data/resources/locales/uk/territories.yml +264 -263
- data/resources/locales/ur/calendars.yml +267 -228
- data/resources/locales/ur/currencies.yml +954 -916
- data/resources/locales/ur/languages.yml +583 -580
- data/resources/locales/ur/layout.yml +5 -5
- data/resources/locales/ur/lists.yml +23 -7
- data/resources/locales/ur/numbers.yml +62 -57
- data/resources/locales/ur/plurals.yml +3 -2
- data/resources/locales/ur/rbnf.yml +4 -0
- data/resources/locales/ur/territories.yml +264 -263
- data/resources/locales/vi/calendars.yml +256 -236
- data/resources/locales/vi/currencies.yml +953 -915
- data/resources/locales/vi/languages.yml +583 -580
- data/resources/locales/vi/layout.yml +5 -5
- data/resources/locales/vi/lists.yml +23 -7
- data/resources/locales/vi/numbers.yml +62 -57
- data/resources/locales/vi/plurals.yml +2 -2
- data/resources/locales/vi/rbnf.yml +164 -0
- data/resources/locales/vi/territories.yml +264 -263
- data/resources/locales/zh/calendars.yml +266 -265
- data/resources/locales/zh/currencies.yml +953 -915
- data/resources/locales/zh/languages.yml +583 -580
- data/resources/locales/zh/layout.yml +5 -5
- data/resources/locales/zh/lists.yml +23 -7
- data/resources/locales/zh/numbers.yml +62 -57
- data/resources/locales/zh/plurals.yml +2 -2
- data/resources/locales/zh/rbnf.yml +689 -0
- data/resources/locales/zh/territories.yml +264 -263
- data/resources/locales/zh-Hant/calendars.yml +266 -265
- data/resources/locales/zh-Hant/currencies.yml +955 -915
- data/resources/locales/zh-Hant/languages.yml +583 -580
- data/resources/locales/zh-Hant/layout.yml +5 -5
- data/resources/locales/zh-Hant/lists.yml +23 -7
- data/resources/locales/zh-Hant/numbers.yml +62 -57
- data/resources/locales/zh-Hant/plurals.yml +2 -2
- data/resources/locales/zh-Hant/rbnf.yml +647 -0
- data/resources/locales/zh-Hant/territories.yml +264 -263
- data/resources/shared/currency_digits_and_rounding.yml +67 -64
- data/resources/shared/numbering_systems.yml +176 -0
- data/resources/shared/rbnf_root.yml +1573 -0
- data/resources/shared/segments/segments_root.yml +728 -0
- data/resources/shared/segments/tailorings/en.yml +8 -0
- data/resources/uli/segments/de.yml +128 -0
- data/resources/uli/segments/en.yml +154 -0
- data/resources/uli/segments/es.yml +112 -0
- data/resources/uli/segments/fr.yml +47 -0
- data/resources/uli/segments/it.yml +37 -0
- data/resources/uli/segments/pt.yml +173 -0
- data/resources/uli/segments/ru.yml +10 -0
- data/resources/unicode_data/casefolding.yml +4765 -0
- data/resources/unicode_data/indices/bidi_class.yml +4572 -0
- data/resources/unicode_data/indices/bidi_mirrored.yml +3087 -0
- data/resources/unicode_data/indices/category.yml +10918 -0
- data/resources/unicode_data/indices/keys.yml +101 -0
- data/resources/unicode_data/properties/line_break.yml +9269 -0
- data/resources/unicode_data/properties/sentence_break.yml +8067 -0
- data/resources/unicode_data/properties/word_break.yml +3001 -0
- data/spec/collation/collation_spec.rb +2 -1
- data/spec/collation/collator_spec.rb +4 -3
- data/spec/collation/tailoring_spec.rb +2 -2
- data/spec/collation/tailoring_tests/he.txt +5 -2
- data/spec/{tokenizers/calendars → data_readers}/additional_date_format_selector_spec.rb +13 -13
- data/spec/data_readers/date_time_data_reader_spec.rb +26 -0
- data/spec/data_readers/number_data_reader_spec.rb +18 -0
- data/spec/data_readers/timespan_data_reader.rb +22 -0
- data/spec/formatters/calendars/datetime_formatter_spec.rb +18 -22
- data/spec/formatters/list_formatter_spec.rb +16 -87
- data/spec/formatters/numbers/abbreviated/abbreviated_number_formatter_spec.rb +15 -59
- data/spec/formatters/numbers/abbreviated/long_decimal_formatter_spec.rb +32 -17
- data/spec/formatters/numbers/abbreviated/short_decimal_formatter_spec.rb +33 -17
- data/spec/formatters/numbers/currency_formatter_spec.rb +18 -13
- data/spec/formatters/numbers/decimal_formatter_spec.rb +16 -18
- data/spec/formatters/numbers/number_formatter_spec.rb +40 -31
- data/spec/formatters/numbers/percent_formatter_spec.rb +14 -6
- data/spec/formatters/numbers/rbnf/allowed_failures.yml +74 -0
- data/spec/formatters/numbers/rbnf/locales/af/rbnf_test.yml +706 -0
- data/spec/formatters/numbers/rbnf/locales/ar/rbnf_test.yml +706 -0
- data/spec/formatters/numbers/rbnf/locales/be/rbnf_test.yml +1174 -0
- data/spec/formatters/numbers/rbnf/locales/bg/rbnf_test.yml +706 -0
- data/spec/formatters/numbers/rbnf/locales/bn/rbnf_test.yml +1291 -0
- data/spec/formatters/numbers/rbnf/locales/ca/rbnf_test.yml +1174 -0
- data/spec/formatters/numbers/rbnf/locales/cs/rbnf_test.yml +823 -0
- data/spec/formatters/numbers/rbnf/locales/cy/rbnf_test.yml +940 -0
- data/spec/formatters/numbers/rbnf/locales/da/rbnf_test.yml +940 -0
- data/spec/formatters/numbers/rbnf/locales/de/rbnf_test.yml +940 -0
- data/spec/formatters/numbers/rbnf/locales/el/rbnf_test.yml +1174 -0
- data/spec/formatters/numbers/rbnf/locales/en/rbnf_test.yml +1291 -0
- data/spec/formatters/numbers/rbnf/locales/en-GB/rbnf_test.yml +1291 -0
- data/spec/formatters/numbers/rbnf/locales/es/rbnf_test.yml +1642 -0
- data/spec/formatters/numbers/rbnf/locales/eu/rbnf_test.yml +1291 -0
- data/spec/formatters/numbers/rbnf/locales/fa/rbnf_test.yml +589 -0
- data/spec/formatters/numbers/rbnf/locales/fi/rbnf_test.yml +706 -0
- data/spec/formatters/numbers/rbnf/locales/fil/rbnf_test.yml +706 -0
- data/spec/formatters/numbers/rbnf/locales/fr/rbnf_test.yml +1408 -0
- data/spec/formatters/numbers/rbnf/locales/ga/rbnf_test.yml +940 -0
- data/spec/formatters/numbers/rbnf/locales/gl/rbnf_test.yml +1291 -0
- data/spec/formatters/numbers/rbnf/locales/he/rbnf_test.yml +1057 -0
- data/spec/formatters/numbers/rbnf/locales/hi/rbnf_test.yml +823 -0
- data/spec/formatters/numbers/rbnf/locales/hr/rbnf_test.yml +1174 -0
- data/spec/formatters/numbers/rbnf/locales/hu/rbnf_test.yml +940 -0
- data/spec/formatters/numbers/rbnf/locales/id/rbnf_test.yml +706 -0
- data/spec/formatters/numbers/rbnf/locales/is/rbnf_test.yml +823 -0
- data/spec/formatters/numbers/rbnf/locales/it/rbnf_test.yml +1174 -0
- data/spec/formatters/numbers/rbnf/locales/ja/rbnf_test.yml +823 -0
- data/spec/formatters/numbers/rbnf/locales/ko/rbnf_test.yml +1408 -0
- data/spec/formatters/numbers/rbnf/locales/lv/rbnf_test.yml +706 -0
- data/spec/formatters/numbers/rbnf/locales/ms/rbnf_test.yml +706 -0
- data/spec/formatters/numbers/rbnf/locales/nb/rbnf_test.yml +940 -0
- data/spec/formatters/numbers/rbnf/locales/nl/rbnf_test.yml +706 -0
- data/spec/formatters/numbers/rbnf/locales/pl/rbnf_test.yml +823 -0
- data/spec/formatters/numbers/rbnf/locales/pt/rbnf_test.yml +1174 -0
- data/spec/formatters/numbers/rbnf/locales/ro/rbnf_test.yml +823 -0
- data/spec/formatters/numbers/rbnf/locales/ru/rbnf_test.yml +823 -0
- data/spec/formatters/numbers/rbnf/locales/sk/rbnf_test.yml +823 -0
- data/spec/formatters/numbers/rbnf/locales/sq/rbnf_test.yml +706 -0
- data/spec/formatters/numbers/rbnf/locales/sr/rbnf_test.yml +940 -0
- data/spec/formatters/numbers/rbnf/locales/sv/rbnf_test.yml +1876 -0
- data/spec/formatters/numbers/rbnf/locales/ta/rbnf_test.yml +706 -0
- data/spec/formatters/numbers/rbnf/locales/th/rbnf_test.yml +706 -0
- data/spec/formatters/numbers/rbnf/locales/tr/rbnf_test.yml +706 -0
- data/spec/formatters/numbers/rbnf/locales/uk/rbnf_test.yml +823 -0
- data/spec/formatters/numbers/rbnf/locales/ur/rbnf_test.yml +1291 -0
- data/spec/formatters/numbers/rbnf/locales/vi/rbnf_test.yml +706 -0
- data/spec/formatters/numbers/rbnf/locales/zh/rbnf_test.yml +940 -0
- data/spec/formatters/numbers/rbnf/locales/zh-Hant/rbnf_test.yml +940 -0
- data/spec/formatters/numbers/rbnf/rbnf_spec.rb +98 -0
- data/spec/formatters/plurals/plural_formatter_spec.rb +4 -4
- data/spec/formatters/plurals/rules_spec.rb +5 -5
- data/spec/localized/localized_date_spec.rb +1 -1
- data/spec/localized/localized_datetime_spec.rb +8 -13
- data/spec/localized/localized_number_spec.rb +17 -32
- data/spec/localized/localized_object_spec.rb +0 -5
- data/spec/localized/localized_string_spec.rb +40 -2
- data/spec/localized/localized_time_spec.rb +3 -6
- data/spec/localized/localized_timespan_spec.rb +144 -0
- data/spec/normalization_spec.rb +12 -12
- data/spec/parsers/number_parser_spec.rb +5 -5
- data/spec/parsers/parser_spec.rb +60 -0
- data/spec/parsers/segmentation_parser_spec.rb +96 -0
- data/spec/parsers/symbol_table_spec.rb +32 -0
- data/spec/parsers/unicode_regex/character_class_spec.rb +117 -0
- data/spec/parsers/unicode_regex/character_range_spec.rb +21 -0
- data/spec/parsers/unicode_regex/character_set_spec.rb +36 -0
- data/spec/parsers/unicode_regex/literal_spec.rb +34 -0
- data/spec/parsers/unicode_regex/unicode_string_spec.rb +22 -0
- data/spec/parsers/unicode_regex_parser_spec.rb +86 -0
- data/spec/readme_spec.rb +8 -269
- data/spec/shared/break_iterator_spec.rb +72 -0
- data/spec/shared/calendar_spec.rb +5 -4
- data/spec/shared/casefolder_spec.rb +30 -0
- data/spec/shared/casefolding.txt +251 -0
- data/spec/shared/casefolding_expected.txt +251 -0
- data/spec/shared/code_point_spec.rb +44 -14
- data/spec/shared/numbering_system_spec.rb +41 -0
- data/spec/shared/territories_spec.rb +14 -6
- data/spec/shared/unicode_regex_spec.rb +203 -0
- data/spec/spec_helper.rb +17 -0
- data/spec/tokenizers/calendars/date_tokenizer_spec.rb +26 -30
- data/spec/tokenizers/calendars/datetime_tokenizer_spec.rb +11 -90
- data/spec/tokenizers/calendars/time_tokenizer_spec.rb +5 -5
- data/spec/tokenizers/calendars/timespan_tokenizer_spec.rb +17 -7
- data/spec/tokenizers/numbers/number_tokenizer_spec.rb +28 -27
- data/spec/tokenizers/segmentation/segmentation_tokenizer_spec.rb +40 -0
- data/spec/tokenizers/unicode_regex/unicode_regex_tokenizer_spec.rb +190 -0
- data/spec/utils/range_set_spec.rb +171 -0
- data/spec/utils/yaml/yaml_spec.rb +62 -51
- data/twitter_cldr.gemspec +1 -1
- metadata +199 -30
- data/lib/twitter_cldr/formatters/base.rb +0 -47
- data/lib/twitter_cldr/formatters/calendars/date_formatter.rb +0 -19
- data/lib/twitter_cldr/formatters/calendars/time_formatter.rb +0 -19
- data/lib/twitter_cldr/normalization/base.rb +0 -37
- data/lib/twitter_cldr/normalization/hangul.rb +0 -79
- data/lib/twitter_cldr/normalization/nfc.rb +0 -24
- data/lib/twitter_cldr/normalization/nfd.rb +0 -26
- data/lib/twitter_cldr/normalization/nfkc.rb +0 -114
- data/lib/twitter_cldr/normalization/nfkd.rb +0 -120
- data/lib/twitter_cldr/normalization/quick_check.rb +0 -41
- data/lib/twitter_cldr/tokenizers/base.rb +0 -169
- data/lib/twitter_cldr/tokenizers/calendars/datetime_tokenizer.rb +0 -131
- data/lib/twitter_cldr/utils/territories.rb +0 -56
- data/spec/formatters/base_spec.rb +0 -18
- data/spec/formatters/calendars/timespan_formatter_spec.rb +0 -112
- data/spec/normalization/NormalizationTestShort.txt +0 -602
- data/spec/normalization/base_spec.rb +0 -16
- data/spec/normalization/hangul_spec.rb +0 -42
- data/spec/normalization/normalization_spec.rb +0 -113
- data/spec/tokenizers/base_spec.rb +0 -259
- data/spec/utils/territories_spec.rb +0 -16
@@ -0,0 +1,98 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
# Copyright 2012 Twitter, Inc
|
4
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
5
|
+
|
6
|
+
require 'spec_helper'
|
7
|
+
|
8
|
+
include TwitterCldr::Formatters::Rbnf
|
9
|
+
|
10
|
+
TEST_FILE_DIR = File.join(File.dirname(__FILE__), "locales")
|
11
|
+
|
12
|
+
def test_file_for(locale)
|
13
|
+
File.join(TEST_FILE_DIR, locale, "rbnf_test.yml")
|
14
|
+
end
|
15
|
+
|
16
|
+
failures = {}
|
17
|
+
|
18
|
+
describe RbnfFormatter do
|
19
|
+
def allowed_failures
|
20
|
+
@allowed_failures ||= begin
|
21
|
+
YAML.load_file(
|
22
|
+
File.join(File.dirname(__FILE__), "allowed_failures.yml")
|
23
|
+
)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def allowed_failure?(options = {})
|
28
|
+
trail = [:locale, :group, :rule_set]
|
29
|
+
dest = trail.inject(allowed_failures) do |ret, leg|
|
30
|
+
if ret && ret[options[leg]]
|
31
|
+
ret[options[leg]]
|
32
|
+
else
|
33
|
+
ret
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
if dest
|
38
|
+
dest.include?(options[:number])
|
39
|
+
else
|
40
|
+
false
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
TwitterCldr.supported_locales.each do |locale|
|
45
|
+
formatter = RbnfFormatter.new(locale)
|
46
|
+
test_data = YAML.load_file(test_file_for(locale.to_s))
|
47
|
+
|
48
|
+
describe locale.localize.as_language_code do
|
49
|
+
formatter.group_names.each do |group_name|
|
50
|
+
|
51
|
+
describe group_name do
|
52
|
+
formatter.rule_set_names_for_group(group_name).each do |rule_set_name|
|
53
|
+
|
54
|
+
describe rule_set_name.gsub("-", " ") do
|
55
|
+
|
56
|
+
# running basic test suite only runs spellout-numbering tests (for speed)
|
57
|
+
it "formats correctly", :slow => rule_set_name != "spellout-numbering" do
|
58
|
+
test_data[group_name][rule_set_name].each_pair do |number, expected|
|
59
|
+
got = formatter.format(number, {
|
60
|
+
:rule_group => group_name,
|
61
|
+
:rule_set => rule_set_name
|
62
|
+
})
|
63
|
+
|
64
|
+
if got != expected
|
65
|
+
opts = {
|
66
|
+
:locale => locale, :group => group_name,
|
67
|
+
:rule_set => rule_set_name, :number => number
|
68
|
+
}
|
69
|
+
|
70
|
+
unless allowed_failure?(opts)
|
71
|
+
failures[locale] ||= {}
|
72
|
+
failures[locale][group_name] ||= {}
|
73
|
+
failures[locale][group_name][rule_set_name] ||= []
|
74
|
+
failures[locale][group_name][rule_set_name] << number
|
75
|
+
got.should == expected
|
76
|
+
end
|
77
|
+
else
|
78
|
+
got.should == expected
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
after(:all) do
|
92
|
+
if failures.size > 0
|
93
|
+
puts "\nFailure hash:"
|
94
|
+
puts failures.inspect
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
@@ -11,11 +11,11 @@ describe PluralFormatter do
|
|
11
11
|
|
12
12
|
describe '#initialize' do
|
13
13
|
it 'fetches locale from options hash' do
|
14
|
-
PluralFormatter.new(:
|
14
|
+
PluralFormatter.new(:ru).locale.should == :ru
|
15
15
|
end
|
16
16
|
|
17
|
-
it "uses
|
18
|
-
PluralFormatter.new.locale.should == TwitterCldr
|
17
|
+
it "uses current locale if it's not passed in options hash" do
|
18
|
+
PluralFormatter.new.locale.should == TwitterCldr.locale
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -198,7 +198,7 @@ describe PluralFormatter do
|
|
198
198
|
describe '#pluralization_rule' do
|
199
199
|
it 'delegates pluralization rule fetching to Rules.rule_for method' do
|
200
200
|
mock(Plurals::Rules).rule_for(42, :jp) { 'result' }
|
201
|
-
PluralFormatter.new(:
|
201
|
+
PluralFormatter.new(:jp).send(:pluralization_rule, 42).should == 'result'
|
202
202
|
end
|
203
203
|
end
|
204
204
|
|
@@ -13,7 +13,7 @@ describe Rules do
|
|
13
13
|
result = Rules.send(:get_resource, :ru)
|
14
14
|
|
15
15
|
result.should include(:keys, :rule)
|
16
|
-
result[:keys].size.should ==
|
16
|
+
result[:keys].size.should == 3
|
17
17
|
result[:rule].should be_a(Proc)
|
18
18
|
end
|
19
19
|
end
|
@@ -29,8 +29,8 @@ describe Rules do
|
|
29
29
|
it "returns the correct values for Russian rules" do
|
30
30
|
rules = {
|
31
31
|
:one => [1, 101],
|
32
|
-
:
|
33
|
-
:
|
32
|
+
:many => ((5..11).to_a + [111]),
|
33
|
+
:other => [2, 3, 4, 102]
|
34
34
|
}
|
35
35
|
|
36
36
|
rules.each do |rule, examples|
|
@@ -48,7 +48,7 @@ describe Rules do
|
|
48
48
|
describe "#all_for" do
|
49
49
|
it "returns a list of all applicable rules for the given locale" do
|
50
50
|
Rules.all_for(:en).should =~ [:one, :other]
|
51
|
-
Rules.all_for(:ru).should =~ [:one, :
|
51
|
+
Rules.all_for(:ru).should =~ [:one, :many, :other]
|
52
52
|
end
|
53
53
|
|
54
54
|
it "returns nil on error" do
|
@@ -61,7 +61,7 @@ describe Rules do
|
|
61
61
|
describe "#all" do
|
62
62
|
it "gets rules for the default locale (usually supplied by FastGettext)" do
|
63
63
|
mock(TwitterCldr).locale { :ru }
|
64
|
-
Rules.all.should =~ [:one, :
|
64
|
+
Rules.all.should =~ [:one, :many, :other]
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
@@ -123,7 +123,7 @@ describe LocalizedDate do
|
|
123
123
|
describe 'formatters' do
|
124
124
|
it "don't raise errors for any locale" do
|
125
125
|
TwitterCldr.supported_locales.each do |locale|
|
126
|
-
(
|
126
|
+
(LocalizedDate.types - [:additional]).each do |type|
|
127
127
|
lambda { DateTime.now.localize(locale).to_date.send(:"to_#{type}_s") }.should_not raise_error
|
128
128
|
end
|
129
129
|
end
|
@@ -63,15 +63,15 @@ describe LocalizedDateTime do
|
|
63
63
|
end
|
64
64
|
|
65
65
|
describe "#to_timespan" do
|
66
|
-
it "should return a localized timespan
|
67
|
-
date_time.localize.to_timespan.
|
66
|
+
it "should return a localized timespan" do
|
67
|
+
date_time.localize.to_timespan.should be_a(LocalizedTimespan)
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
71
|
describe 'formatters' do
|
72
72
|
it "don't raise errors for any locale" do
|
73
73
|
TwitterCldr.supported_locales.each do |locale|
|
74
|
-
(TwitterCldr::
|
74
|
+
(TwitterCldr::DataReaders::CalendarDataReader.types - [:additional]).each do |type|
|
75
75
|
lambda { date_time.localize(locale).send(:"to_#{type}_s") }.should_not raise_error
|
76
76
|
end
|
77
77
|
end
|
@@ -79,10 +79,11 @@ describe LocalizedDateTime do
|
|
79
79
|
|
80
80
|
it "don't raise errors for additional date formats" do
|
81
81
|
TwitterCldr.supported_locales.each do |locale|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
lambda { date_time.localize(locale).
|
82
|
+
data_reader = CalendarDataReader.new(locale)
|
83
|
+
data_reader.additional_format_selector.patterns.each do |pattern|
|
84
|
+
# puts "#{locale}: #{pattern}"
|
85
|
+
# lambda { date_time.localize(locale).to_additional_s(pattern.to_s) }.should_not raise_error
|
86
|
+
date_time.localize(locale).to_additional_s(pattern.to_s)
|
86
87
|
end
|
87
88
|
end
|
88
89
|
end
|
@@ -94,12 +95,6 @@ describe LocalizedDateTime do
|
|
94
95
|
mock.proxy(loc_date).to_default_s
|
95
96
|
loc_date.to_s.should == "Sep 20, 1987, 10:05:00 PM"
|
96
97
|
end
|
97
|
-
|
98
|
-
it "uses the given format instead of the default when specified" do
|
99
|
-
loc_date = date_time.localize
|
100
|
-
mock.proxy(loc_date).to_default_s.never
|
101
|
-
date_time.localize.to_s(:format => "MMMd").should == "Sep 20"
|
102
|
-
end
|
103
98
|
end
|
104
99
|
|
105
100
|
describe "#with_timezone" do
|
@@ -13,29 +13,17 @@ describe LocalizedNumber do
|
|
13
13
|
let(:decimal) { LocalizedNumber.new(10, :en) }
|
14
14
|
let(:currency) { LocalizedNumber.new(10, :en, :type => :currency) }
|
15
15
|
|
16
|
-
it 'uses
|
17
|
-
decimal.type.should ==
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'setups DecimalFormatter by default' do
|
21
|
-
decimal.formatter.should be_an_instance_of(TwitterCldr::Formatters::DecimalFormatter)
|
16
|
+
it 'uses nil type by default (defers decision to data reader)' do
|
17
|
+
decimal.type.should == nil
|
22
18
|
end
|
23
19
|
|
24
20
|
it 'uses provided type if there is one' do
|
25
21
|
currency.type.should == :currency
|
26
22
|
end
|
27
23
|
|
28
|
-
it '
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
it 'setups formatter with correct locale' do
|
33
|
-
mock.proxy(TwitterCldr::Formatters::DecimalFormatter).new(:locale => :es)
|
34
|
-
LocalizedNumber.new(10, :es)
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'raises ArguemntError if unsupported type is passed' do
|
38
|
-
lambda { LocalizedNumber.new(10, :en, :type => :foo) }.should raise_error(ArgumentError, 'type foo is not supported')
|
24
|
+
it 'sets up object with correct locale, falls back to default locale' do
|
25
|
+
LocalizedNumber.new(10, :es).locale.should == :es
|
26
|
+
LocalizedNumber.new(10, :blarg).locale.should == TwitterCldr::DEFAULT_LOCALE
|
39
27
|
end
|
40
28
|
end
|
41
29
|
|
@@ -43,7 +31,7 @@ describe LocalizedNumber do
|
|
43
31
|
let(:number) { LocalizedNumber.new(10, :en) }
|
44
32
|
let(:currency) { LocalizedNumber.new(10, :en, :type => :currency) }
|
45
33
|
|
46
|
-
LocalizedNumber
|
34
|
+
LocalizedNumber.types.each do |type|
|
47
35
|
describe "#to_#{type}" do
|
48
36
|
let(:method) { "to_#{type}" }
|
49
37
|
|
@@ -51,7 +39,7 @@ describe LocalizedNumber do
|
|
51
39
|
number.send(method).object_id.should_not == number.object_id
|
52
40
|
end
|
53
41
|
|
54
|
-
it 'creates an object of appropriate type, but does not change the type of the original object' do
|
42
|
+
it 'creates an object of the appropriate type, but does not change the type of the original object' do
|
55
43
|
new_number = currency.send(method)
|
56
44
|
new_number.type.should == type
|
57
45
|
currency.type.should == :currency
|
@@ -59,24 +47,29 @@ describe LocalizedNumber do
|
|
59
47
|
|
60
48
|
it 'creates a new object with the same base object and locale' do
|
61
49
|
percent = LocalizedNumber.new(42, :fr, :type => :percent)
|
62
|
-
|
63
|
-
|
50
|
+
new_percent = percent.send(method)
|
51
|
+
new_percent.locale.should == :fr
|
52
|
+
new_percent.base_obj.should == 42
|
64
53
|
end
|
65
54
|
end
|
66
55
|
end
|
67
56
|
end
|
68
57
|
|
69
58
|
describe '#to_s' do
|
59
|
+
it 'raises ArguemntError if unsupported type is passed' do
|
60
|
+
lambda do
|
61
|
+
LocalizedNumber.new(10, :en, :type => :foo).to_s
|
62
|
+
end.should raise_error(ArgumentError, 'Type foo is not supported')
|
63
|
+
end
|
64
|
+
|
70
65
|
context 'decimals' do
|
71
66
|
let(:number) { LocalizedNumber.new(10, :en) }
|
72
67
|
|
73
68
|
it 'should default precision to zero' do
|
74
|
-
mock.proxy(number.formatter).format(number.base_obj, { :type => :decimal })
|
75
69
|
number.to_s.should == "10"
|
76
70
|
end
|
77
71
|
|
78
72
|
it 'should not overwrite precision when explicitly passed' do
|
79
|
-
mock.proxy(number.formatter).format(number.base_obj, :precision => 2, :type => :decimal)
|
80
73
|
number.to_s(:precision => 2).should == "10.00"
|
81
74
|
end
|
82
75
|
end
|
@@ -85,12 +78,10 @@ describe LocalizedNumber do
|
|
85
78
|
let(:number) { LocalizedNumber.new(10, :en, :type => :currency) }
|
86
79
|
|
87
80
|
it "should default to a precision of 2" do
|
88
|
-
mock.proxy(number.formatter).format(number.base_obj, :precision => 2, :type => :currency)
|
89
81
|
number.to_s(:precision => 2).should == "$10.00"
|
90
82
|
end
|
91
83
|
|
92
84
|
it 'should not overwrite precision when explicitly passed' do
|
93
|
-
mock.proxy(number.formatter).format(number.base_obj, :precision => 1, :type => :currency)
|
94
85
|
number.to_s(:precision => 1).should == "$10.0"
|
95
86
|
end
|
96
87
|
end
|
@@ -99,12 +90,10 @@ describe LocalizedNumber do
|
|
99
90
|
let(:number) { LocalizedNumber.new(10, :en, :type => :percent) }
|
100
91
|
|
101
92
|
it "should default to a precision of 0" do
|
102
|
-
mock.proxy(number.formatter).format(number.base_obj, { :type => :percent })
|
103
93
|
number.to_s.should == "10%"
|
104
94
|
end
|
105
95
|
|
106
96
|
it 'should not overwrite precision when explicitly passed' do
|
107
|
-
mock.proxy(number.formatter).format(number.base_obj, :precision => 1, :type => :percent)
|
108
97
|
number.to_s(:precision => 1).should == "10.0%"
|
109
98
|
end
|
110
99
|
end
|
@@ -113,12 +102,10 @@ describe LocalizedNumber do
|
|
113
102
|
let(:number) { LocalizedNumber.new(1000, :en, :type => :short_decimal) }
|
114
103
|
|
115
104
|
it "should default to a precision of 0" do
|
116
|
-
mock.proxy(number.formatter).format(number.base_obj, { :type => :short_decimal })
|
117
105
|
number.to_s.should == "1K"
|
118
106
|
end
|
119
107
|
|
120
108
|
it 'should not overwrite precision when explicitly passed' do
|
121
|
-
mock.proxy(number.formatter).format(number.base_obj, :precision => 1, :type => :short_decimal)
|
122
109
|
number.to_s(:precision => 1).should == "1.0K"
|
123
110
|
end
|
124
111
|
end
|
@@ -127,12 +114,10 @@ describe LocalizedNumber do
|
|
127
114
|
let(:number) { LocalizedNumber.new(1000, :en, :type => :long_decimal) }
|
128
115
|
|
129
116
|
it "should default to a precision of 0" do
|
130
|
-
mock.proxy(number.formatter).format(number.base_obj, { :type => :long_decimal })
|
131
117
|
number.to_s.should == "1 thousand"
|
132
118
|
end
|
133
119
|
|
134
120
|
it 'should not overwrite precision when explicitly passed' do
|
135
|
-
mock.proxy(number.formatter).format(number.base_obj, :precision => 1, :type => :long_decimal)
|
136
121
|
number.to_s(:precision => 1).should == "1.0 thousand"
|
137
122
|
end
|
138
123
|
end
|
@@ -141,7 +126,7 @@ describe LocalizedNumber do
|
|
141
126
|
describe '#plural_rule' do
|
142
127
|
it 'returns the appropriate plural rule for the number' do
|
143
128
|
1.localize(:ru).plural_rule.should == :one
|
144
|
-
2.localize(:ru).plural_rule.should == :
|
129
|
+
2.localize(:ru).plural_rule.should == :other
|
145
130
|
5.localize(:ru).plural_rule.should == :many
|
146
131
|
end
|
147
132
|
|
@@ -41,11 +41,6 @@ describe LocalizedObject do
|
|
41
41
|
LocalizedClass.new(base_object, :foobar).locale.should == TwitterCldr::DEFAULT_LOCALE
|
42
42
|
end
|
43
43
|
|
44
|
-
it 'passes options (including locale) to formatter' do
|
45
|
-
mock(LocalizedFormatter).new(options.merge(:locale => locale))
|
46
|
-
LocalizedClass.new(base_object, locale, options)
|
47
|
-
end
|
48
|
-
|
49
44
|
it "doesn't change original options hash" do
|
50
45
|
lambda { LocalizedClass.new(base_object, locale, options) }.should_not change { options }
|
51
46
|
end
|
@@ -133,12 +133,12 @@ describe LocalizedString do
|
|
133
133
|
end
|
134
134
|
|
135
135
|
it 'it uses NFD by default' do
|
136
|
-
mock(
|
136
|
+
mock(Eprun).normalize(string, :nfd) { normalized_string }
|
137
137
|
localized_string.normalize.base_obj.should == normalized_string
|
138
138
|
end
|
139
139
|
|
140
140
|
it "uses specified algorithm if there is any" do
|
141
|
-
mock(
|
141
|
+
mock(Eprun).normalize(string, :nfkd) { normalized_string }
|
142
142
|
localized_string.normalize(:using => :NFKD).base_obj.should == normalized_string
|
143
143
|
end
|
144
144
|
|
@@ -147,6 +147,44 @@ describe LocalizedString do
|
|
147
147
|
end
|
148
148
|
end
|
149
149
|
|
150
|
+
describe "#casefold" do
|
151
|
+
it 'returns a LocalizedString' do
|
152
|
+
str = "Weißrussland".localize.casefold
|
153
|
+
str.should be_an_instance_of(LocalizedString)
|
154
|
+
str.to_s.should == "weissrussland"
|
155
|
+
end
|
156
|
+
|
157
|
+
it 'does not pass the t option by default' do
|
158
|
+
"Istanbul".localize.casefold.to_s.should == "istanbul"
|
159
|
+
end
|
160
|
+
|
161
|
+
it 'uses the t option when explicitly given' do
|
162
|
+
"Istanbul".localize.casefold(:t => true).to_s.should == "ıstanbul"
|
163
|
+
end
|
164
|
+
|
165
|
+
it 'uses t by default if the locale is tr (az not supported)' do
|
166
|
+
"Istanbul".localize(:tr).casefold.to_s.should == "ıstanbul"
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
describe "#each_sentence" do
|
171
|
+
it "returns an enumerator if not passed a block" do
|
172
|
+
"foo bar".localize.each_sentence.should be_a(Enumerator)
|
173
|
+
end
|
174
|
+
|
175
|
+
it "yields sentences as localized strings" do
|
176
|
+
str = "Quick. Brown. Fox.".localize
|
177
|
+
|
178
|
+
str.each_sentence do |sentence|
|
179
|
+
sentence.should be_a(LocalizedString)
|
180
|
+
end
|
181
|
+
|
182
|
+
str.each_sentence.to_a.map(&:to_s).should == [
|
183
|
+
"Quick.", " Brown.", " Fox."
|
184
|
+
]
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
150
188
|
describe "#code_points" do
|
151
189
|
it "returns an array of Unicode code points for the string" do
|
152
190
|
"español".localize.code_points.should == [0x65, 0x73, 0x70, 0x61, 0xF1, 0x6F, 0x6C]
|
@@ -32,11 +32,8 @@ describe LocalizedTime do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
describe "#ago" do
|
35
|
-
it "should
|
36
|
-
|
37
|
-
loc_time = time.localize(:de)
|
38
|
-
loc_time.ago(:base_time => base_time).to_s(:unit => :hour).should match_normalized("Vor 48 Stunden")
|
39
|
-
loc_time.ago(:base_time => base_time).to_s(:unit => :day).should match_normalized("Vor 2 Tagen")
|
35
|
+
it "should return a localized timespan" do
|
36
|
+
time.localize(:de).ago.should be_a(LocalizedTimespan)
|
40
37
|
end
|
41
38
|
end
|
42
39
|
|
@@ -61,7 +58,7 @@ describe LocalizedTime do
|
|
61
58
|
describe 'formatters' do
|
62
59
|
it "don't raise errors for any locale" do
|
63
60
|
TwitterCldr.supported_locales.each do |locale|
|
64
|
-
(
|
61
|
+
(CalendarDataReader.types - [:additional]).each do |type|
|
65
62
|
lambda { Time.now.localize(locale).send(:"to_#{type}_s") }.should_not raise_error
|
66
63
|
end
|
67
64
|
end
|
@@ -0,0 +1,144 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
# Copyright 2012 Twitter, Inc
|
4
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
5
|
+
|
6
|
+
require 'spec_helper'
|
7
|
+
|
8
|
+
include TwitterCldr::Localized
|
9
|
+
|
10
|
+
describe LocalizedTimespan do
|
11
|
+
it "should format a numer of seconds in different units" do
|
12
|
+
timespan = LocalizedTimespan.new(-172800, :locale => :de)
|
13
|
+
timespan.to_s(:unit => :hour).should match_normalized("Vor 48 Stunden")
|
14
|
+
timespan.to_s(:unit => :day).should match_normalized("Vor 2 Tagen")
|
15
|
+
end
|
16
|
+
|
17
|
+
it "approximates timespans accurately if explicity asked" do
|
18
|
+
options = {
|
19
|
+
:direction => :none,
|
20
|
+
:approximate => true
|
21
|
+
}
|
22
|
+
|
23
|
+
expected = {
|
24
|
+
44 => "44 Sekunden",
|
25
|
+
45 => "1 Minute",
|
26
|
+
2699 => "45 Minuten",
|
27
|
+
2700 => "1 Stunde",
|
28
|
+
64799 => "18 Stunden",
|
29
|
+
64800 => "1 Tag",
|
30
|
+
453599 => "5 Tage",
|
31
|
+
453600 => "1 Woche",
|
32
|
+
1972307 => "3 Wochen",
|
33
|
+
1972308 => "1 Monat",
|
34
|
+
23667694 => "9 Monate",
|
35
|
+
23667695 => "1 Jahr"
|
36
|
+
}
|
37
|
+
|
38
|
+
expected.each_pair do |seconds, text|
|
39
|
+
timespan = LocalizedTimespan.new(seconds, :locale => :de)
|
40
|
+
timespan.to_s(options).should match_normalized(text)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
it "doesn't approximate timespans by default" do
|
45
|
+
options = { :direction => :none }
|
46
|
+
expected = {
|
47
|
+
44 => "44 Sekunden",
|
48
|
+
45 => "45 Sekunden",
|
49
|
+
2699 => "45 Minuten",
|
50
|
+
2700 => "45 Minuten",
|
51
|
+
64799 => "18 Stunden",
|
52
|
+
64800 => "18 Stunden",
|
53
|
+
453599 => "5 Tage",
|
54
|
+
453600 => "5 Tage",
|
55
|
+
1972307 => "3 Wochen",
|
56
|
+
1972308 => "3 Wochen",
|
57
|
+
23667694 => "9 Monate",
|
58
|
+
23667695 => "9 Monate",
|
59
|
+
31556926 => "1 Jahr"
|
60
|
+
}
|
61
|
+
|
62
|
+
expected.each_pair do |seconds, text|
|
63
|
+
timespan = LocalizedTimespan.new(seconds, :locale => :de)
|
64
|
+
timespan.to_s(options).should match_normalized(text)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe "non-directional" do
|
69
|
+
it "works for a variety of units" do
|
70
|
+
timespan = LocalizedTimespan.new(3273932, :locale => :de)
|
71
|
+
options = { :direction => :none }
|
72
|
+
expected = {
|
73
|
+
:year => '0 Jahre',
|
74
|
+
:month => '1 Monat',
|
75
|
+
:week => '5 Wochen',
|
76
|
+
:day => '38 Tage',
|
77
|
+
:hour => '909 Stunden',
|
78
|
+
:minute => '54566 Minuten',
|
79
|
+
:second => '3273932 Sekunden'
|
80
|
+
}
|
81
|
+
|
82
|
+
expected.each_pair do |unit, text|
|
83
|
+
timespan.to_s(options.merge(:unit => unit)).should match_normalized(text)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "ago" do
|
89
|
+
it "works for a variety of units" do
|
90
|
+
timespan = LocalizedTimespan.new(-3273932, :locale => :de)
|
91
|
+
expected = {
|
92
|
+
:year => 'Vor 0 Jahren',
|
93
|
+
:month => 'Vor 1 Monat',
|
94
|
+
:week => 'Vor 5 Wochen',
|
95
|
+
:day => 'Vor 38 Tagen',
|
96
|
+
:hour => 'Vor 909 Stunden',
|
97
|
+
:minute => 'Vor 54566 Minuten',
|
98
|
+
:second => 'Vor 3273932 Sekunden'
|
99
|
+
}
|
100
|
+
|
101
|
+
expected.each_pair do |unit, text|
|
102
|
+
timespan.to_s(:unit => unit).should match_normalized(text)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe "#until" do
|
108
|
+
it "works for a variety of units" do
|
109
|
+
timespan = LocalizedTimespan.new(3273932, :locale => :de)
|
110
|
+
expected = {
|
111
|
+
:year => 'In 0 Jahren',
|
112
|
+
:month => 'In 1 Monat',
|
113
|
+
:week => 'In 5 Wochen',
|
114
|
+
:day => 'In 38 Tagen',
|
115
|
+
:hour => 'In 909 Stunden',
|
116
|
+
:minute => 'In 54566 Minuten',
|
117
|
+
:second => 'In 3273932 Sekunden'
|
118
|
+
}
|
119
|
+
|
120
|
+
expected.each_pair do |unit, text|
|
121
|
+
timespan.to_s(:unit => unit).should match_normalized(text)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
# Note: non-directional timespans are the only ones that support the abbreviated type (i.e. ago and until cannot be abbreviated)
|
127
|
+
describe "non-directional" do
|
128
|
+
it "works for a variety of units" do
|
129
|
+
# year/month/week not supported
|
130
|
+
timespan = LocalizedTimespan.new(3273932)
|
131
|
+
options = { :type => :abbreviated, :direction => :none }
|
132
|
+
expected = {
|
133
|
+
:day => '38d',
|
134
|
+
:hour => '909h',
|
135
|
+
:minute => '54566m',
|
136
|
+
:second => '3273932s'
|
137
|
+
}
|
138
|
+
|
139
|
+
expected.each_pair do |unit, text|
|
140
|
+
timespan.to_s(options.merge(:unit => unit)).should match_normalized(text)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
data/spec/normalization_spec.rb
CHANGED
@@ -5,8 +5,6 @@
|
|
5
5
|
|
6
6
|
require 'spec_helper'
|
7
7
|
|
8
|
-
include TwitterCldr
|
9
|
-
|
10
8
|
describe TwitterCldr::Normalization do
|
11
9
|
|
12
10
|
describe "#normalize" do
|
@@ -14,27 +12,29 @@ describe TwitterCldr::Normalization do
|
|
14
12
|
let(:normalized_string) { 'normalized' }
|
15
13
|
|
16
14
|
it 'it uses NFD by default' do
|
17
|
-
mock(
|
18
|
-
Normalization.normalize(string).should == normalized_string
|
15
|
+
mock(Eprun).normalize(string, :nfd) { normalized_string }
|
16
|
+
TwitterCldr::Normalization.normalize(string).should == normalized_string
|
19
17
|
end
|
20
18
|
|
21
19
|
it "uses specified algorithm if there is any" do
|
22
|
-
mock(
|
23
|
-
Normalization.normalize(string, :using => :
|
20
|
+
mock(Eprun).normalize(string, :nfkd) { normalized_string }
|
21
|
+
TwitterCldr::Normalization.normalize(string, :using => :nfkd).should == normalized_string
|
24
22
|
end
|
25
23
|
|
26
24
|
it "raises an ArgumentError if passed an unsupported normalizer name" do
|
27
|
-
lambda
|
25
|
+
lambda do
|
26
|
+
TwitterCldr::Normalization.normalize(string, :using => :blarg)
|
27
|
+
end.should raise_error(ArgumentError)
|
28
28
|
end
|
29
29
|
|
30
|
-
it 'accepts normalizer name in
|
31
|
-
mock(
|
32
|
-
Normalization.normalize(string, :using => :
|
30
|
+
it 'accepts normalizer name in upper case' do
|
31
|
+
mock(Eprun).normalize(string, :nfkd) { normalized_string }
|
32
|
+
TwitterCldr::Normalization.normalize(string, :using => :NFKD).should == normalized_string
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'accepts a string' do
|
36
|
-
mock(
|
37
|
-
Normalization.normalize(string, :using => '
|
36
|
+
mock(Eprun).normalize(string, :nfkd) { normalized_string }
|
37
|
+
TwitterCldr::Normalization.normalize(string, :using => 'nfkd').should == normalized_string
|
38
38
|
end
|
39
39
|
|
40
40
|
end
|