twitter_cldr 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/NOTICE +95 -1
- data/README.md +4 -4
- data/Rakefile +18 -28
- data/lib/ext/calendars/date.rb +3 -0
- data/lib/ext/calendars/datetime.rb +3 -0
- data/lib/ext/calendars/time.rb +3 -0
- data/lib/ext/localized_object.rb +3 -0
- data/lib/ext/numbers/bignum.rb +3 -0
- data/lib/ext/numbers/fixnum.rb +3 -0
- data/lib/ext/numbers/float.rb +3 -0
- data/lib/ext/numbers/localized_number.rb +3 -0
- data/lib/ext/strings/string.rb +31 -0
- data/lib/ext/strings/symbol.rb +3 -0
- data/lib/formatters/base.rb +3 -0
- data/lib/formatters/calendars/date_formatter.rb +3 -0
- data/lib/formatters/calendars/datetime_formatter.rb +3 -0
- data/lib/formatters/calendars/time_formatter.rb +3 -0
- data/lib/formatters/numbers/currency_formatter.rb +3 -0
- data/lib/formatters/numbers/decimal_formatter.rb +3 -0
- data/lib/formatters/numbers/helpers/base.rb +3 -0
- data/lib/formatters/numbers/helpers/fraction.rb +3 -0
- data/lib/formatters/numbers/helpers/integer.rb +3 -0
- data/lib/formatters/numbers/number_formatter.rb +3 -0
- data/lib/formatters/numbers/percent_formatter.rb +3 -0
- data/lib/formatters/plurals/plural_formatter.rb +141 -0
- data/lib/formatters/plurals/rules.rb +4 -1
- data/lib/normalizers/base.rb +17 -0
- data/lib/normalizers/canonical/nfd.rb +81 -0
- data/lib/shared/currencies.rb +4 -1
- data/lib/shared/languages.rb +4 -1
- data/lib/shared/resources.rb +8 -28
- data/lib/shared/timezones.rb +3 -0
- data/lib/shared/unicode_data.rb +44 -0
- data/lib/tokenizers/base.rb +3 -0
- data/lib/tokenizers/calendars/date_tokenizer.rb +3 -0
- data/lib/tokenizers/calendars/datetime_tokenizer.rb +4 -1
- data/lib/tokenizers/calendars/time_tokenizer.rb +3 -0
- data/lib/tokenizers/key_path.rb +3 -0
- data/lib/tokenizers/numbers/number_tokenizer.rb +4 -1
- data/lib/tokenizers/token.rb +3 -0
- data/lib/twitter_cldr.rb +52 -29
- data/lib/utils/interpolation.rb +105 -0
- data/lib/utils.rb +28 -0
- data/lib/version.rb +6 -1
- data/resources/unicode_data/aegean_numbers.yml +913 -0
- data/resources/unicode_data/alchemical_symbols.yml +1857 -0
- data/resources/unicode_data/alphabetic_presentation_forms.yml +929 -0
- data/resources/unicode_data/ancient_greek_musical_notation.yml +1121 -0
- data/resources/unicode_data/ancient_greek_numbers.yml +1201 -0
- data/resources/unicode_data/ancient_symbols.yml +193 -0
- data/resources/unicode_data/arabic.yml +4049 -0
- data/resources/unicode_data/arabic_extended_a.yml +625 -0
- data/resources/unicode_data/arabic_mathematical_alphabetic_symbols.yml +2289 -0
- data/resources/unicode_data/arabic_presentation_forms_a.yml +9777 -0
- data/resources/unicode_data/arabic_presentation_forms_b.yml +2257 -0
- data/resources/unicode_data/arabic_supplement.yml +769 -0
- data/resources/unicode_data/armenian.yml +1393 -0
- data/resources/unicode_data/arrows.yml +1793 -0
- data/resources/unicode_data/avestan.yml +977 -0
- data/resources/unicode_data/balinese.yml +1937 -0
- data/resources/unicode_data/bamum.yml +1409 -0
- data/resources/unicode_data/bamum_supplement.yml +9105 -0
- data/resources/unicode_data/basic_latin.yml +2049 -0
- data/resources/unicode_data/batak.yml +897 -0
- data/resources/unicode_data/bengali.yml +1473 -0
- data/resources/unicode_data/block_elements.yml +513 -0
- data/resources/unicode_data/blocks.yml +881 -0
- data/resources/unicode_data/bopomofo.yml +657 -0
- data/resources/unicode_data/bopomofo_extended.yml +433 -0
- data/resources/unicode_data/box_drawing.yml +2049 -0
- data/resources/unicode_data/brahmi.yml +1729 -0
- data/resources/unicode_data/braille_patterns.yml +4097 -0
- data/resources/unicode_data/buginese.yml +481 -0
- data/resources/unicode_data/buhid.yml +321 -0
- data/resources/unicode_data/byzantine_musical_symbols.yml +3937 -0
- data/resources/unicode_data/carian.yml +785 -0
- data/resources/unicode_data/chakma.yml +1073 -0
- data/resources/unicode_data/cham.yml +1329 -0
- data/resources/unicode_data/cherokee.yml +1361 -0
- data/resources/unicode_data/cjk_compatibility.yml +4097 -0
- data/resources/unicode_data/cjk_compatibility_forms.yml +513 -0
- data/resources/unicode_data/cjk_compatibility_ideographs.yml +7553 -0
- data/resources/unicode_data/cjk_compatibility_ideographs_supplement.yml +8673 -0
- data/resources/unicode_data/cjk_radicals_supplement.yml +1841 -0
- data/resources/unicode_data/cjk_strokes.yml +577 -0
- data/resources/unicode_data/cjk_symbols_and_punctuation.yml +1025 -0
- data/resources/unicode_data/cjk_unified_ideographs.yml +33 -0
- data/resources/unicode_data/cjk_unified_ideographs_extension_a.yml +33 -0
- data/resources/unicode_data/cjk_unified_ideographs_extension_b.yml +33 -0
- data/resources/unicode_data/cjk_unified_ideographs_extension_c.yml +33 -0
- data/resources/unicode_data/cjk_unified_ideographs_extension_d.yml +33 -0
- data/resources/unicode_data/combining_diacritical_marks.yml +1793 -0
- data/resources/unicode_data/combining_diacritical_marks_for_symbols.yml +529 -0
- data/resources/unicode_data/combining_diacritical_marks_supplement.yml +689 -0
- data/resources/unicode_data/combining_half_marks.yml +113 -0
- data/resources/unicode_data/common_indic_number_forms.yml +161 -0
- data/resources/unicode_data/control_pictures.yml +625 -0
- data/resources/unicode_data/coptic.yml +1969 -0
- data/resources/unicode_data/counting_rod_numerals.yml +289 -0
- data/resources/unicode_data/cuneiform.yml +14065 -0
- data/resources/unicode_data/cuneiform_numbers_and_punctuation.yml +1649 -0
- data/resources/unicode_data/currency_symbols.yml +417 -0
- data/resources/unicode_data/cypriot_syllabary.yml +881 -0
- data/resources/unicode_data/cyrillic.yml +4097 -0
- data/resources/unicode_data/cyrillic_extended_a.yml +513 -0
- data/resources/unicode_data/cyrillic_extended_b.yml +1425 -0
- data/resources/unicode_data/cyrillic_supplement.yml +641 -0
- data/resources/unicode_data/deseret.yml +1281 -0
- data/resources/unicode_data/devanagari.yml +2033 -0
- data/resources/unicode_data/devanagari_extended.yml +449 -0
- data/resources/unicode_data/dingbats.yml +3057 -0
- data/resources/unicode_data/domino_tiles.yml +1601 -0
- data/resources/unicode_data/egyptian_hieroglyphs.yml +17137 -0
- data/resources/unicode_data/emoticons.yml +1217 -0
- data/resources/unicode_data/enclosed_alphanumeric_supplement.yml +2737 -0
- data/resources/unicode_data/enclosed_alphanumerics.yml +2561 -0
- data/resources/unicode_data/enclosed_cjk_letters_and_months.yml +4065 -0
- data/resources/unicode_data/enclosed_ideographic_supplement.yml +913 -0
- data/resources/unicode_data/ethiopic.yml +5729 -0
- data/resources/unicode_data/ethiopic_extended.yml +1265 -0
- data/resources/unicode_data/ethiopic_extended_a.yml +513 -0
- data/resources/unicode_data/ethiopic_supplement.yml +417 -0
- data/resources/unicode_data/general_punctuation.yml +1713 -0
- data/resources/unicode_data/geometric_shapes.yml +1537 -0
- data/resources/unicode_data/georgian.yml +1409 -0
- data/resources/unicode_data/georgian_supplement.yml +641 -0
- data/resources/unicode_data/glagolitic.yml +1505 -0
- data/resources/unicode_data/gothic.yml +433 -0
- data/resources/unicode_data/greek_and_coptic.yml +2145 -0
- data/resources/unicode_data/greek_extended.yml +3729 -0
- data/resources/unicode_data/gujarati.yml +1345 -0
- data/resources/unicode_data/gurmukhi.yml +1265 -0
- data/resources/unicode_data/halfwidth_and_fullwidth_forms.yml +3601 -0
- data/resources/unicode_data/hangul_compatibility_jamo.yml +1505 -0
- data/resources/unicode_data/hangul_jamo.yml +4097 -0
- data/resources/unicode_data/hangul_jamo_extended_a.yml +465 -0
- data/resources/unicode_data/hangul_jamo_extended_b.yml +1153 -0
- data/resources/unicode_data/hangul_syllables.yml +33 -0
- data/resources/unicode_data/hanunoo.yml +369 -0
- data/resources/unicode_data/hebrew.yml +1393 -0
- data/resources/unicode_data/high_private_use_surrogates.yml +33 -0
- data/resources/unicode_data/high_surrogates.yml +33 -0
- data/resources/unicode_data/hiragana.yml +1489 -0
- data/resources/unicode_data/ideographic_description_characters.yml +193 -0
- data/resources/unicode_data/imperial_aramaic.yml +497 -0
- data/resources/unicode_data/inscriptional_pahlavi.yml +433 -0
- data/resources/unicode_data/inscriptional_parthian.yml +481 -0
- data/resources/unicode_data/ipa_extensions.yml +1537 -0
- data/resources/unicode_data/javanese.yml +1457 -0
- data/resources/unicode_data/kaithi.yml +1057 -0
- data/resources/unicode_data/kana_supplement.yml +33 -0
- data/resources/unicode_data/kanbun.yml +257 -0
- data/resources/unicode_data/kangxi_radicals.yml +3425 -0
- data/resources/unicode_data/kannada.yml +1377 -0
- data/resources/unicode_data/katakana.yml +1537 -0
- data/resources/unicode_data/katakana_phonetic_extensions.yml +257 -0
- data/resources/unicode_data/kayah_li.yml +769 -0
- data/resources/unicode_data/kharoshthi.yml +1041 -0
- data/resources/unicode_data/khmer.yml +1825 -0
- data/resources/unicode_data/khmer_symbols.yml +513 -0
- data/resources/unicode_data/lao.yml +1073 -0
- data/resources/unicode_data/latin_1_supplement.yml +2049 -0
- data/resources/unicode_data/latin_extended_a.yml +2049 -0
- data/resources/unicode_data/latin_extended_additional.yml +4097 -0
- data/resources/unicode_data/latin_extended_b.yml +3329 -0
- data/resources/unicode_data/latin_extended_c.yml +513 -0
- data/resources/unicode_data/latin_extended_d.yml +2145 -0
- data/resources/unicode_data/lepcha.yml +1185 -0
- data/resources/unicode_data/letterlike_symbols.yml +1281 -0
- data/resources/unicode_data/limbu.yml +1057 -0
- data/resources/unicode_data/linear_b_ideograms.yml +1969 -0
- data/resources/unicode_data/linear_b_syllabary.yml +1409 -0
- data/resources/unicode_data/lisu.yml +769 -0
- data/resources/unicode_data/low_surrogates.yml +33 -0
- data/resources/unicode_data/lycian.yml +465 -0
- data/resources/unicode_data/lydian.yml +433 -0
- data/resources/unicode_data/mahjong_tiles.yml +705 -0
- data/resources/unicode_data/malayalam.yml +1569 -0
- data/resources/unicode_data/mandaic.yml +465 -0
- data/resources/unicode_data/mathematical_alphanumeric_symbols.yml +15937 -0
- data/resources/unicode_data/mathematical_operators.yml +4097 -0
- data/resources/unicode_data/meetei_mayek.yml +897 -0
- data/resources/unicode_data/meetei_mayek_extensions.yml +369 -0
- data/resources/unicode_data/meroitic_cursive.yml +417 -0
- data/resources/unicode_data/meroitic_hieroglyphs.yml +513 -0
- data/resources/unicode_data/miao.yml +2129 -0
- data/resources/unicode_data/miscellaneous_mathematical_symbols_a.yml +769 -0
- data/resources/unicode_data/miscellaneous_mathematical_symbols_b.yml +2049 -0
- data/resources/unicode_data/miscellaneous_symbols.yml +4097 -0
- data/resources/unicode_data/miscellaneous_symbols_and_arrows.yml +1393 -0
- data/resources/unicode_data/miscellaneous_symbols_and_pictographs.yml +8529 -0
- data/resources/unicode_data/miscellaneous_technical.yml +3905 -0
- data/resources/unicode_data/modifier_tone_letters.yml +513 -0
- data/resources/unicode_data/mongolian.yml +2497 -0
- data/resources/unicode_data/musical_symbols.yml +3521 -0
- data/resources/unicode_data/myanmar.yml +2561 -0
- data/resources/unicode_data/myanmar_extended_a.yml +449 -0
- data/resources/unicode_data/new_tai_lue.yml +1329 -0
- data/resources/unicode_data/nko.yml +945 -0
- data/resources/unicode_data/number_forms.yml +929 -0
- data/resources/unicode_data/ogham.yml +465 -0
- data/resources/unicode_data/ol_chiki.yml +769 -0
- data/resources/unicode_data/old_italic.yml +561 -0
- data/resources/unicode_data/old_persian.yml +801 -0
- data/resources/unicode_data/old_south_arabian.yml +513 -0
- data/resources/unicode_data/old_turkic.yml +1169 -0
- data/resources/unicode_data/optical_character_recognition.yml +177 -0
- data/resources/unicode_data/oriya.yml +1441 -0
- data/resources/unicode_data/osmanya.yml +641 -0
- data/resources/unicode_data/phags_pa.yml +897 -0
- data/resources/unicode_data/phaistos_disc.yml +737 -0
- data/resources/unicode_data/phoenician.yml +465 -0
- data/resources/unicode_data/phonetic_extensions.yml +2049 -0
- data/resources/unicode_data/phonetic_extensions_supplement.yml +1025 -0
- data/resources/unicode_data/playing_cards.yml +945 -0
- data/resources/unicode_data/private_use_area.yml +33 -0
- data/resources/unicode_data/rejang.yml +593 -0
- data/resources/unicode_data/rumi_numeral_symbols.yml +497 -0
- data/resources/unicode_data/runic.yml +1297 -0
- data/resources/unicode_data/samaritan.yml +977 -0
- data/resources/unicode_data/saurashtra.yml +1297 -0
- data/resources/unicode_data/sharada.yml +1329 -0
- data/resources/unicode_data/shavian.yml +769 -0
- data/resources/unicode_data/sinhala.yml +1281 -0
- data/resources/unicode_data/small_form_variants.yml +417 -0
- data/resources/unicode_data/sora_sompeng.yml +561 -0
- data/resources/unicode_data/spacing_modifier_letters.yml +1281 -0
- data/resources/unicode_data/specials.yml +81 -0
- data/resources/unicode_data/sundanese.yml +1025 -0
- data/resources/unicode_data/sundanese_supplement.yml +129 -0
- data/resources/unicode_data/superscripts_and_subscripts.yml +673 -0
- data/resources/unicode_data/supplemental_arrows_a.yml +257 -0
- data/resources/unicode_data/supplemental_arrows_b.yml +2049 -0
- data/resources/unicode_data/supplemental_mathematical_operators.yml +4097 -0
- data/resources/unicode_data/supplemental_punctuation.yml +961 -0
- data/resources/unicode_data/supplementary_private_use_area_a.yml +33 -0
- data/resources/unicode_data/supplementary_private_use_area_b.yml +33 -0
- data/resources/unicode_data/syloti_nagri.yml +705 -0
- data/resources/unicode_data/syriac.yml +1233 -0
- data/resources/unicode_data/tagalog.yml +321 -0
- data/resources/unicode_data/tagbanwa.yml +289 -0
- data/resources/unicode_data/tags.yml +1553 -0
- data/resources/unicode_data/tai_le.yml +561 -0
- data/resources/unicode_data/tai_tham.yml +2033 -0
- data/resources/unicode_data/tai_viet.yml +1153 -0
- data/resources/unicode_data/tai_xuan_jing_symbols.yml +1393 -0
- data/resources/unicode_data/takri.yml +1057 -0
- data/resources/unicode_data/tamil.yml +1153 -0
- data/resources/unicode_data/telugu.yml +1489 -0
- data/resources/unicode_data/thaana.yml +801 -0
- data/resources/unicode_data/thai.yml +1393 -0
- data/resources/unicode_data/tibetan.yml +3377 -0
- data/resources/unicode_data/tifinagh.yml +945 -0
- data/resources/unicode_data/transport_and_map_symbols.yml +1121 -0
- data/resources/unicode_data/ugaritic.yml +497 -0
- data/resources/unicode_data/unified_canadian_aboriginal_syllabics.yml +10241 -0
- data/resources/unicode_data/unified_canadian_aboriginal_syllabics_extended.yml +1121 -0
- data/resources/unicode_data/vai.yml +4801 -0
- data/resources/unicode_data/variation_selectors.yml +257 -0
- data/resources/unicode_data/variation_selectors_supplement.yml +3841 -0
- data/resources/unicode_data/vedic_extensions.yml +625 -0
- data/resources/unicode_data/vertical_forms.yml +161 -0
- data/resources/unicode_data/yi_radicals.yml +881 -0
- data/resources/unicode_data/yi_syllables.yml +18641 -0
- data/resources/unicode_data/yijing_hexagram_symbols.yml +1025 -0
- data/spec/ext/calendars/date_spec.rb +5 -1
- data/spec/ext/calendars/datetime_spec.rb +5 -1
- data/spec/ext/calendars/time_spec.rb +5 -1
- data/spec/ext/numbers/bignum_spec.rb +5 -1
- data/spec/ext/numbers/fixnum_spec.rb +5 -1
- data/spec/ext/numbers/float_spec.rb +5 -1
- data/spec/ext/numbers/localized_number_spec.rb +5 -1
- data/spec/ext/strings/string_spec.rb +102 -0
- data/spec/ext/strings/symbol_spec.rb +5 -1
- data/spec/formatters/base_spec.rb +5 -1
- data/spec/formatters/calendars/datetime_formatter_spec.rb +5 -1
- data/spec/formatters/numbers/currency_formatter_spec.rb +5 -1
- data/spec/formatters/numbers/decimal_formatter_spec.rb +5 -1
- data/spec/formatters/numbers/helpers/fraction_spec.rb +5 -1
- data/spec/formatters/numbers/helpers/integer_spec.rb +5 -1
- data/spec/formatters/numbers/number_formatter_spec.rb +6 -2
- data/spec/formatters/numbers/percent_formatter_spec.rb +5 -1
- data/spec/formatters/plurals/plural_formatter_spec.rb +205 -0
- data/spec/formatters/plurals/rules_spec.rb +28 -28
- data/spec/normalizers/NormalizationTest.txt +602 -0
- data/spec/normalizers/base_spec.rb +16 -0
- data/spec/normalizers/canonical/nfd_spec.rb +50 -0
- data/spec/shared/currencies_spec.rb +5 -1
- data/spec/shared/languages_spec.rb +5 -1
- data/spec/shared/resources_spec.rb +5 -18
- data/spec/shared/unicode_data_spec.rb +51 -0
- data/spec/spec_helper.rb +6 -3
- data/spec/tokenizers/base_spec.rb +3 -0
- data/spec/tokenizers/calendars/date_tokenizer_spec.rb +5 -1
- data/spec/tokenizers/calendars/datetime_tokenizer_spec.rb +5 -1
- data/spec/tokenizers/calendars/time_tokenizer_spec.rb +5 -1
- data/spec/tokenizers/key_path_spec.rb +3 -0
- data/spec/tokenizers/numbers/number_tokenizer_spec.rb +5 -1
- data/spec/tokenizers/token_spec.rb +5 -1
- data/spec/twitter_cldr_spec.rb +23 -1
- data/spec/utils/interpolation_spec.rb +124 -0
- data/spec/utils_spec.rb +32 -0
- metadata +285 -21
data/NOTICE
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
twitter-cldr-rb is a Ruby implementation of the Common Locale Data Repository
|
|
1
|
+
twitter-cldr-rb is a Ruby implementation of the Common Locale Data Repository
|
|
2
2
|
Copyright (C) 2012 Twitter, Inc.
|
|
3
3
|
|
|
4
|
+
|
|
4
5
|
Portions of this gem were borrowed from Sven Fuchs' ruby-cldr gem. Here is
|
|
5
6
|
the license that accompanied Mr. Fuchs' code:
|
|
6
7
|
|
|
@@ -24,3 +25,96 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
|
24
25
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
25
26
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
26
27
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
Backporting of String interpolation from Ruby 1.9 to Ruby 1.8 implemented in
|
|
31
|
+
this gem (see file interpolation.rb) was partially copied and heavily based
|
|
32
|
+
on the implementation of i18n and gettext gems. Below are the license agreements
|
|
33
|
+
that accompanied these gems.
|
|
34
|
+
|
|
35
|
+
License agreement of the i18n gem (https://github.com/svenfuchs/i18n):
|
|
36
|
+
|
|
37
|
+
Copyright (c) 2008 The Ruby I18n team
|
|
38
|
+
|
|
39
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
40
|
+
a copy of this software and associated documentation files (the
|
|
41
|
+
"Software"), to deal in the Software without restriction, including
|
|
42
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
43
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
44
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
45
|
+
the following conditions:
|
|
46
|
+
|
|
47
|
+
The above copyright notice and this permission notice shall be
|
|
48
|
+
included in all copies or substantial portions of the Software.
|
|
49
|
+
|
|
50
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
51
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
52
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
53
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
54
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
55
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
56
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
57
|
+
|
|
58
|
+
License of the gettext gem (https://github.com/mutoh/gettext):
|
|
59
|
+
|
|
60
|
+
Copyright (C) 2005-2009 Masao Mutoh
|
|
61
|
+
|
|
62
|
+
You may redistribute it [the code] and/or modify it under the same license
|
|
63
|
+
terms as Ruby or LGPL [http://www.gnu.org/licenses/lgpl-3.0.txt].
|
|
64
|
+
|
|
65
|
+
Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
|
|
66
|
+
You can redistribute it and/or modify it under either the terms of the GPL
|
|
67
|
+
version 2 (see the file GPL), or the conditions below:
|
|
68
|
+
|
|
69
|
+
1. You may make and give away verbatim copies of the source form of the
|
|
70
|
+
software without restriction, provided that you duplicate all of the
|
|
71
|
+
original copyright notices and associated disclaimers.
|
|
72
|
+
|
|
73
|
+
2. You may modify your copy of the software in any way, provided that
|
|
74
|
+
you do at least ONE of the following:
|
|
75
|
+
|
|
76
|
+
a) place your modifications in the Public Domain or otherwise
|
|
77
|
+
make them Freely Available, such as by posting said
|
|
78
|
+
modifications to Usenet or an equivalent medium, or by allowing
|
|
79
|
+
the author to include your modifications in the software.
|
|
80
|
+
|
|
81
|
+
b) use the modified software only within your corporation or
|
|
82
|
+
organization.
|
|
83
|
+
|
|
84
|
+
c) give non-standard binaries non-standard names, with
|
|
85
|
+
instructions on where to get the original software distribution.
|
|
86
|
+
|
|
87
|
+
d) make other distribution arrangements with the author.
|
|
88
|
+
|
|
89
|
+
3. You may distribute the software in object code or binary form,
|
|
90
|
+
provided that you do at least ONE of the following:
|
|
91
|
+
|
|
92
|
+
a) distribute the binaries and library files of the software,
|
|
93
|
+
together with instructions (in the manual page or equivalent)
|
|
94
|
+
on where to get the original distribution.
|
|
95
|
+
|
|
96
|
+
b) accompany the distribution with the machine-readable source of
|
|
97
|
+
the software.
|
|
98
|
+
|
|
99
|
+
c) give non-standard binaries non-standard names, with
|
|
100
|
+
instructions on where to get the original software distribution.
|
|
101
|
+
|
|
102
|
+
d) make other distribution arrangements with the author.
|
|
103
|
+
|
|
104
|
+
4. You may modify and include the part of the software into any other
|
|
105
|
+
software (possibly commercial). But some files in the distribution
|
|
106
|
+
are not written by the author, so that they are not under these terms.
|
|
107
|
+
|
|
108
|
+
For the list of those files and their copying conditions, see the
|
|
109
|
+
file LEGAL.
|
|
110
|
+
|
|
111
|
+
5. The scripts and library files supplied as input to or produced as
|
|
112
|
+
output from the software do not automatically fall under the
|
|
113
|
+
copyright of the software, but belong to whomever generated them,
|
|
114
|
+
and may be sold commercially, and may be aggregated with this
|
|
115
|
+
software.
|
|
116
|
+
|
|
117
|
+
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
|
118
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
|
119
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
120
|
+
PURPOSE.
|
data/README.md
CHANGED
|
@@ -49,8 +49,8 @@ Fixnum, Bignum, and Float objects are supported. Here are some examples:
|
|
|
49
49
|
|
|
50
50
|
# currencies, default USD
|
|
51
51
|
1337.localize(:es).to_currency.to_s # $1.337,00
|
|
52
|
-
1337.localize(:es).to_currency.to_s(:currency => "EUR") # €1.337,00
|
|
53
|
-
1337.localize(:es).to_currency.to_s(:currency => "Peru") # S/.1.337,00
|
|
52
|
+
1337.localize(:es).to_currency.to_s(:currency => "EUR") # € 1.337,00
|
|
53
|
+
1337.localize(:es).to_currency.to_s(:currency => "Peru") # S/. 1.337,00
|
|
54
54
|
|
|
55
55
|
# percentages
|
|
56
56
|
1337.localize(:es).to_percent.to_s # 1.337%
|
|
@@ -84,7 +84,7 @@ TwitterCldr::Shared::Currencies.currency_codes # ["LTL", "PHP" ... ]
|
|
|
84
84
|
TwitterCldr::Shared::Currencies.for_country("Canada") # { :currency => "Dollar", :symbol => "$", :code => "CAD" }
|
|
85
85
|
|
|
86
86
|
# data for a specific currency code
|
|
87
|
-
TwitterCldr::Shared::Currencies.for_code("CAD") # { :currency => "Dollar", :symbol => "$", :
|
|
87
|
+
TwitterCldr::Shared::Currencies.for_code("CAD") # { :currency => "Dollar", :symbol => "$", :country => "Canada"}
|
|
88
88
|
```
|
|
89
89
|
|
|
90
90
|
### Dates and Times
|
|
@@ -150,7 +150,7 @@ You can use the localize convenience method on language code symbols to get thei
|
|
|
150
150
|
|
|
151
151
|
```ruby
|
|
152
152
|
:es.localize(:es).as_language_code # "español"
|
|
153
|
-
:ru.localize(:es).
|
|
153
|
+
:ru.localize(:es).as_language_code # "ruso"
|
|
154
154
|
```
|
|
155
155
|
|
|
156
156
|
Behind the scenes, these convenience methods are creating instances of LocalizedSymbol. You can do the same thing if you're feeling adventurous:
|
data/Rakefile
CHANGED
|
@@ -1,36 +1,26 @@
|
|
|
1
1
|
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
|
2
|
-
require 'rake/gempackagetask'
|
|
3
|
-
require 'rake/rdoctask'
|
|
4
|
-
require 'rubygems/specification'
|
|
5
|
-
require 'spec/rake/spectask'
|
|
6
|
-
require 'spec/rake/verify_rcov'
|
|
7
|
-
require 'digest'
|
|
8
|
-
|
|
9
|
-
spec = Gem::Specification.load("#{File.dirname(__FILE__)}/twitter_cldr.gemspec")
|
|
10
2
|
|
|
11
|
-
|
|
3
|
+
require 'rspec/core/rake_task'
|
|
4
|
+
require 'rubygems/package_task'
|
|
5
|
+
require File.join(File.dirname(__FILE__), "lib/version")
|
|
12
6
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
|
16
|
-
t.spec_opts = %w(-fs --color)
|
|
17
|
-
t.libs << ["spec", '.']
|
|
18
|
-
end
|
|
7
|
+
require 'bundler'
|
|
8
|
+
require 'digest'
|
|
19
9
|
|
|
20
|
-
|
|
21
|
-
Spec::Rake::SpecTask.new('spec:rcov') do |t|
|
|
22
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
|
23
|
-
t.rcov = true
|
|
24
|
-
t.rcov_opts = ['-T', '--sort', 'coverage', '--exclude', 'gems/*,spec/*']
|
|
25
|
-
end
|
|
10
|
+
Bundler::GemHelper.install_tasks
|
|
26
11
|
|
|
27
|
-
|
|
28
|
-
Rake::GemPackageTask.new(spec) do |pkg|
|
|
29
|
-
pkg.gem_spec = spec
|
|
30
|
-
end
|
|
12
|
+
task :default => :spec
|
|
31
13
|
|
|
32
|
-
desc
|
|
33
|
-
|
|
34
|
-
|
|
14
|
+
desc 'Run specs'
|
|
15
|
+
RSpec::Core::RakeTask.new do |t|
|
|
16
|
+
t.pattern = './spec/**/*_spec.rb'
|
|
35
17
|
end
|
|
36
18
|
|
|
19
|
+
if RUBY_VERSION < '1.9.0'
|
|
20
|
+
desc 'Run all examples with RCov'
|
|
21
|
+
RSpec::Core::RakeTask.new('spec:rcov') do |t|
|
|
22
|
+
t.rcov = true
|
|
23
|
+
t.pattern = './spec/**/*_spec.rb'
|
|
24
|
+
t.rcov_opts = %w(-T --sort coverage --exclude gems/,spec/)
|
|
25
|
+
end
|
|
26
|
+
end
|
data/lib/ext/calendars/date.rb
CHANGED
data/lib/ext/calendars/time.rb
CHANGED
data/lib/ext/localized_object.rb
CHANGED
data/lib/ext/numbers/bignum.rb
CHANGED
data/lib/ext/numbers/fixnum.rb
CHANGED
data/lib/ext/numbers/float.rb
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
3
|
+
# Copyright 2012 Twitter, Inc
|
|
4
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
5
|
+
|
|
6
|
+
class String
|
|
7
|
+
def localize(locale = TwitterCldr.get_locale)
|
|
8
|
+
TwitterCldr::LocalizedString.new(self, locale)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
module TwitterCldr
|
|
13
|
+
class LocalizedString < LocalizedObject
|
|
14
|
+
|
|
15
|
+
# Uses wrapped string object as a format specification and returns the result of applying it to +args+ (see
|
|
16
|
+
# +TwitterCldr::Utils.interpolate+ method for interpolation syntax).
|
|
17
|
+
#
|
|
18
|
+
# If +args+ is a Hash than pluralization is performed before interpolation (see +PluralFormatter+ class for
|
|
19
|
+
# pluralization specification).
|
|
20
|
+
#
|
|
21
|
+
def %(args)
|
|
22
|
+
pluralized = args.is_a?(Hash) ? @formatter.format(@base_obj, args) : @base_obj
|
|
23
|
+
TwitterCldr::Utils.interpolate(pluralized, args)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def formatter_const
|
|
27
|
+
TwitterCldr::Formatters::PluralFormatter
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
end
|
data/lib/ext/strings/symbol.rb
CHANGED
data/lib/formatters/base.rb
CHANGED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
3
|
+
# Copyright 2012 Twitter, Inc
|
|
4
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
5
|
+
|
|
6
|
+
require 'json'
|
|
7
|
+
|
|
8
|
+
module TwitterCldr
|
|
9
|
+
module Formatters
|
|
10
|
+
class PluralFormatter < Base
|
|
11
|
+
|
|
12
|
+
PLURALIZATION_REGEXP = Regexp.union(
|
|
13
|
+
/%\{(\w+?):(\w+?)\}/, # regular pluralization pattern
|
|
14
|
+
/%<(\{.*?\})>/ # inline pluralization pattern
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
attr_accessor :locale
|
|
18
|
+
|
|
19
|
+
def initialize(options = {})
|
|
20
|
+
self.locale = extract_locale(options)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Replaces every pluralization token in the +string+ with a phrase formed using a number and a pluralization
|
|
24
|
+
# pattern from the +replacements+ hash.
|
|
25
|
+
#
|
|
26
|
+
# Two types of formatting are supported for pluralization.
|
|
27
|
+
#
|
|
28
|
+
# * Regular pluralization:
|
|
29
|
+
#
|
|
30
|
+
# Format of a pluralization group is '%{number:objects}'. When pluralization group like that is encountered in
|
|
31
|
+
# the +string+, +replacements+ hash is expected to contain a number and pluralization patterns at keys +:number+
|
|
32
|
+
# and +:objects+ respectively (note, keys of the +replacements+ hash should be symbols).
|
|
33
|
+
#
|
|
34
|
+
# Pluralization patterns are specified as a hash containing a pattern for every plural category of the language.
|
|
35
|
+
# Keys of this hash should be symbols. If necessary, pluralization pattern can contain placeholder for the number.
|
|
36
|
+
# Syntax for the placeholder is similar to the hash-based string interpolation: '%{number}.
|
|
37
|
+
#
|
|
38
|
+
# * Inline pluralization:
|
|
39
|
+
#
|
|
40
|
+
# Pluralization group if formatted as '%<{ "number": { "one": "one horse" } }>'. Content inside '%<...>' is
|
|
41
|
+
# expected to be a valid string representation of a JSON object with a single key-value pair (JSON property),
|
|
42
|
+
# where key matches key in the +replacements+ hash (e.g., in this example +replacements+ hash can be something
|
|
43
|
+
# like { :number => 3 }), and value is a hash (JSON object) of pluralization rules to be used with this number.
|
|
44
|
+
# No space is allowed inside opening '%<{' and closing '}>' sequences. As pluralization group is parsed as JSON
|
|
45
|
+
# all keys and string values inside it should be enclosed in double quotes.
|
|
46
|
+
#
|
|
47
|
+
# Examples:
|
|
48
|
+
#
|
|
49
|
+
# f.format('%{count:horses}', :count => 1, :horses => { :one => 'one horse', :other => '%{count} horses' })
|
|
50
|
+
# # => "one horse"
|
|
51
|
+
#
|
|
52
|
+
# f.format('%{count:horses}', :count => 2, :horses => { :one => 'one horse', :other => '%{count} horses' })
|
|
53
|
+
# # => "2 horses"
|
|
54
|
+
#
|
|
55
|
+
# f.format('%<{ "count": {"one": "one horse", "other": "%{count} horses"} }>', :count => 2)
|
|
56
|
+
# # => "2 horses"
|
|
57
|
+
#
|
|
58
|
+
# Multiple pluralization groups can be present in the same string.
|
|
59
|
+
#
|
|
60
|
+
# Examples:
|
|
61
|
+
#
|
|
62
|
+
# f.format(
|
|
63
|
+
# '%{ponies_count:ponies} and %{unicorns_count:unicorns}',
|
|
64
|
+
# :ponies_count => 2, :ponies => { :one => 'one pony', :other => '%{ponies_count} ponies' },
|
|
65
|
+
# :unicorns_count => 1, :unicorns => { :one => 'one unicorn', :other => '%{unicorns_count} unicorns' }
|
|
66
|
+
# )
|
|
67
|
+
# # => "2 ponies and one unicorn"
|
|
68
|
+
#
|
|
69
|
+
# The same applies to inline pluralization.
|
|
70
|
+
#
|
|
71
|
+
# Mixed styles of pluralization (both regular and inline) can be used in the same string, but it's better to avoid
|
|
72
|
+
# that as it might bring more confusion than real benefit.
|
|
73
|
+
#
|
|
74
|
+
# If a number or required pluralization pattern is missing in the +replacements+ hash, corresponding
|
|
75
|
+
# pluralization token is ignored.
|
|
76
|
+
#
|
|
77
|
+
# Examples:
|
|
78
|
+
#
|
|
79
|
+
# f.format('%{count:horses}', :horses => { :one => 'one horse', :other => '%{count} horses' })
|
|
80
|
+
# # => "%{count:horses}"
|
|
81
|
+
#
|
|
82
|
+
# f.format('%<{"count": {"one": "one horse", "other": "%{count} horses"}}>', {})
|
|
83
|
+
# # => '%<{"count": {"one": "one horse", "other": "%{count} horses"}}>'
|
|
84
|
+
#
|
|
85
|
+
# f.format('%{count:horses}', :count => 10, :horses => { :one => 'one horse' })
|
|
86
|
+
# # => "%{count:horses}"
|
|
87
|
+
#
|
|
88
|
+
# f.format('%<{"count": {"one": "one horse"}}>', :count => 2)
|
|
89
|
+
# # => '%<{"count": {"one": "one horse"}}>'
|
|
90
|
+
#
|
|
91
|
+
# f.format('%{count:horses}', {})
|
|
92
|
+
# # => "%{count:horses}"
|
|
93
|
+
#
|
|
94
|
+
def format(string, replacements)
|
|
95
|
+
string.gsub(PLURALIZATION_REGEXP) do |match|
|
|
96
|
+
number_placeholder, patterns = if $3
|
|
97
|
+
parse_inline_pluralization($3)
|
|
98
|
+
else
|
|
99
|
+
[$1, replacements[$2.to_sym]]
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
number = replacements[number_placeholder.to_sym]
|
|
103
|
+
pattern = pluralization_pattern(patterns, number)
|
|
104
|
+
|
|
105
|
+
pattern && interpolate_pattern(pattern, number_placeholder, number) || match
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
private
|
|
110
|
+
|
|
111
|
+
def parse_inline_pluralization(captured_group)
|
|
112
|
+
pluralization_hash = JSON.parse(captured_group)
|
|
113
|
+
|
|
114
|
+
if pluralization_hash.is_a?(Hash) && pluralization_hash.size == 1
|
|
115
|
+
pluralization_hash.first
|
|
116
|
+
else
|
|
117
|
+
raise ArgumentError.new('expected a Hash with a single key')
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def pluralization_rule(number)
|
|
122
|
+
TwitterCldr::Formatters::Plurals::Rules.rule_for(number, locale)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def pluralization_pattern(patterns, number)
|
|
126
|
+
return unless number && patterns
|
|
127
|
+
|
|
128
|
+
if patterns.is_a?(Hash)
|
|
129
|
+
TwitterCldr::Utils.deep_symbolize_keys(patterns)[pluralization_rule(number)]
|
|
130
|
+
else
|
|
131
|
+
raise ArgumentError.new('expected patterns to be a Hash')
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def interpolate_pattern(pattern, placeholder, number)
|
|
136
|
+
pattern.gsub("%{#{placeholder}}", number.to_s)
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
end
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# encoding: UTF-8
|
|
2
2
|
|
|
3
|
+
# Copyright 2012 Twitter, Inc
|
|
4
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
5
|
+
|
|
3
6
|
module TwitterCldr
|
|
4
7
|
module Formatters
|
|
5
8
|
module Plurals
|
|
@@ -27,7 +30,7 @@ module TwitterCldr
|
|
|
27
30
|
|
|
28
31
|
def get_resource(locale)
|
|
29
32
|
locale = TwitterCldr.convert_locale(locale)
|
|
30
|
-
eval(TwitterCldr.
|
|
33
|
+
eval(TwitterCldr.get_resource(locale, "plurals")[locale])
|
|
31
34
|
end
|
|
32
35
|
end
|
|
33
36
|
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
3
|
+
module TwitterCldr
|
|
4
|
+
module Normalizers
|
|
5
|
+
class Base
|
|
6
|
+
class << self
|
|
7
|
+
def code_point_to_char(code_point)
|
|
8
|
+
[code_point.upcase.hex].pack('U*')
|
|
9
|
+
end
|
|
10
|
+
def char_to_code_point(char)
|
|
11
|
+
code_point = char.unpack('U*').first.to_s(16).upcase
|
|
12
|
+
code_point.rjust(4, '0') #Pad to at least 4 digits
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|