pepe-i18n 0.2.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/CHANGELOG.textile +57 -0
- data/MIT-LICENSE +20 -0
- data/README.textile +42 -0
- data/Rakefile +21 -0
- data/VERSION +1 -0
- data/lib/i18n.rb +270 -0
- data/lib/i18n/backend/base.rb +251 -0
- data/lib/i18n/backend/cache.rb +71 -0
- data/lib/i18n/backend/chain.rb +64 -0
- data/lib/i18n/backend/fallbacks.rb +53 -0
- data/lib/i18n/backend/gettext.rb +65 -0
- data/lib/i18n/backend/pluralization.rb +56 -0
- data/lib/i18n/backend/simple.rb +23 -0
- data/lib/i18n/exceptions.rb +61 -0
- data/lib/i18n/gettext.rb +25 -0
- data/lib/i18n/helpers/gettext.rb +35 -0
- data/lib/i18n/locale/fallbacks.rb +100 -0
- data/lib/i18n/locale/tag.rb +27 -0
- data/lib/i18n/locale/tag/parents.rb +24 -0
- data/lib/i18n/locale/tag/rfc4646.rb +78 -0
- data/lib/i18n/locale/tag/simple.rb +44 -0
- data/lib/i18n/string.rb +95 -0
- data/test/all.rb +5 -0
- data/test/api/basics.rb +15 -0
- data/test/api/interpolation.rb +85 -0
- data/test/api/lambda.rb +52 -0
- data/test/api/link.rb +47 -0
- data/test/api/localization/date.rb +65 -0
- data/test/api/localization/date_time.rb +63 -0
- data/test/api/localization/lambda.rb +26 -0
- data/test/api/localization/time.rb +63 -0
- data/test/api/pluralization.rb +37 -0
- data/test/api/translation.rb +51 -0
- data/test/backend/cache/cache_test.rb +57 -0
- data/test/backend/chain/api_test.rb +80 -0
- data/test/backend/chain/chain_test.rb +64 -0
- data/test/backend/fallbacks/api_test.rb +79 -0
- data/test/backend/fallbacks/fallbacks_test.rb +29 -0
- data/test/backend/pluralization/api_test.rb +81 -0
- data/test/backend/pluralization/pluralization_test.rb +39 -0
- data/test/backend/simple/all.rb +5 -0
- data/test/backend/simple/api_test.rb +90 -0
- data/test/backend/simple/lookup_test.rb +24 -0
- data/test/backend/simple/setup.rb +147 -0
- data/test/backend/simple/translations_test.rb +89 -0
- data/test/fixtures/locales/de.po +61 -0
- data/test/fixtures/locales/en.rb +3 -0
- data/test/fixtures/locales/en.yml +3 -0
- data/test/fixtures/locales/plurals.rb +112 -0
- data/test/gettext/api_test.rb +78 -0
- data/test/gettext/backend_test.rb +35 -0
- data/test/i18n_exceptions_test.rb +97 -0
- data/test/i18n_load_path_test.rb +23 -0
- data/test/i18n_test.rb +163 -0
- data/test/locale/fallbacks_test.rb +128 -0
- data/test/locale/tag/rfc4646_test.rb +147 -0
- data/test/locale/tag/simple_test.rb +35 -0
- data/test/string_test.rb +94 -0
- data/test/test_helper.rb +71 -0
- data/test/with_options.rb +34 -0
- metadata +151 -0
| @@ -0,0 +1,147 @@ | |
| 1 | 
            +
            # encoding: utf-8
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require File.dirname(__FILE__) + '/../../test_helper.rb'
         | 
| 4 | 
            +
            require 'i18n/locale/tag'
         | 
| 5 | 
            +
            require 'i18n/locale/tag/rfc4646'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            # Rfc4646::Parser
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            class I18nLocaleTagRfc4646ParserTest < Test::Unit::TestCase
         | 
| 10 | 
            +
              include I18n::Locale
         | 
| 11 | 
            +
              
         | 
| 12 | 
            +
              test "Rfc4646::Parser given a valid tag 'de' returns an array of subtags" do
         | 
| 13 | 
            +
                assert_equal ['de', nil, nil, nil, nil, nil, nil], Tag::Rfc4646::Parser.match('de')
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              test "Rfc4646::Parser given a valid tag 'de' returns an array of subtags" do
         | 
| 17 | 
            +
                assert_equal ['de', nil, 'DE', nil, nil, nil, nil], Tag::Rfc4646::Parser.match('de-DE')
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
              test "Rfc4646::Parser given a valid lowercase tag 'de-latn-de-variant-x-phonebk' returns an array of subtags" do
         | 
| 21 | 
            +
                assert_equal ['de', 'latn', 'de', 'variant', nil, 'x-phonebk', nil], Tag::Rfc4646::Parser.match('de-latn-de-variant-x-phonebk')
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
              test "Rfc4646::Parser given a valid uppercase tag 'DE-LATN-DE-VARIANT-X-PHONEBK' returns an array of subtags" do
         | 
| 25 | 
            +
                assert_equal ['DE', 'LATN', 'DE', 'VARIANT', nil, 'X-PHONEBK', nil], Tag::Rfc4646::Parser.match('DE-LATN-DE-VARIANT-X-PHONEBK')
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
              test "Rfc4646::Parser given an invalid tag 'a-DE' it returns false" do
         | 
| 29 | 
            +
                assert_equal false, Tag::Rfc4646::Parser.match('a-DE')
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
              test "Rfc4646::Parser given an invalid tag 'de-419-DE' it returns false" do
         | 
| 33 | 
            +
                assert_equal false, Tag::Rfc4646::Parser.match('de-419-DE')
         | 
| 34 | 
            +
              end
         | 
| 35 | 
            +
            end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
            # Tag for the locale 'de-Latn-DE-Variant-a-ext-x-phonebk-i-klingon'
         | 
| 38 | 
            +
             | 
| 39 | 
            +
            class I18nLocaleTagSubtagsTest < Test::Unit::TestCase
         | 
| 40 | 
            +
              include I18n::Locale
         | 
| 41 | 
            +
              
         | 
| 42 | 
            +
              def setup
         | 
| 43 | 
            +
                subtags = %w(de Latn DE variant a-ext x-phonebk i-klingon)
         | 
| 44 | 
            +
                @tag = Tag::Rfc4646.new *subtags
         | 
| 45 | 
            +
              end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
              test "returns 'de' as the language subtag in lowercase" do
         | 
| 48 | 
            +
                assert_equal 'de', @tag.language
         | 
| 49 | 
            +
              end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
              test "returns 'Latn' as the script subtag in titlecase" do
         | 
| 52 | 
            +
                assert_equal 'Latn', @tag.script
         | 
| 53 | 
            +
              end
         | 
| 54 | 
            +
             | 
| 55 | 
            +
              test "returns 'DE' as the region subtag in uppercase" do
         | 
| 56 | 
            +
                assert_equal 'DE', @tag.region
         | 
| 57 | 
            +
              end
         | 
| 58 | 
            +
             | 
| 59 | 
            +
              test "returns 'variant' as the variant subtag in lowercase" do
         | 
| 60 | 
            +
                assert_equal 'variant', @tag.variant
         | 
| 61 | 
            +
              end
         | 
| 62 | 
            +
             | 
| 63 | 
            +
              test "returns 'a-ext' as the extension subtag" do
         | 
| 64 | 
            +
                assert_equal 'a-ext', @tag.extension
         | 
| 65 | 
            +
              end
         | 
| 66 | 
            +
             | 
| 67 | 
            +
              test "returns 'x-phonebk' as the privateuse subtag" do
         | 
| 68 | 
            +
                assert_equal 'x-phonebk', @tag.privateuse
         | 
| 69 | 
            +
              end
         | 
| 70 | 
            +
             | 
| 71 | 
            +
              test "returns 'i-klingon' as the grandfathered subtag" do
         | 
| 72 | 
            +
                assert_equal 'i-klingon', @tag.grandfathered
         | 
| 73 | 
            +
              end
         | 
| 74 | 
            +
             | 
| 75 | 
            +
              test "returns a formatted tag string from #to_s" do
         | 
| 76 | 
            +
                assert_equal 'de-Latn-DE-variant-a-ext-x-phonebk-i-klingon', @tag.to_s
         | 
| 77 | 
            +
              end
         | 
| 78 | 
            +
             | 
| 79 | 
            +
              test "returns an array containing the formatted subtags from #to_a" do
         | 
| 80 | 
            +
                assert_equal %w(de Latn DE variant a-ext x-phonebk i-klingon), @tag.to_a
         | 
| 81 | 
            +
              end
         | 
| 82 | 
            +
            end
         | 
| 83 | 
            +
             | 
| 84 | 
            +
            # Tag inheritance
         | 
| 85 | 
            +
             | 
| 86 | 
            +
            class I18nLocaleTagSubtagsTest < Test::Unit::TestCase
         | 
| 87 | 
            +
              test "#parent returns 'de-Latn-DE-variant-a-ext-x-phonebk' as the parent of 'de-Latn-DE-variant-a-ext-x-phonebk-i-klingon'" do
         | 
| 88 | 
            +
                tag = Tag::Rfc4646.new *%w(de Latn DE variant a-ext x-phonebk i-klingon)
         | 
| 89 | 
            +
                assert_equal 'de-Latn-DE-variant-a-ext-x-phonebk', tag.parent.to_s
         | 
| 90 | 
            +
              end
         | 
| 91 | 
            +
             | 
| 92 | 
            +
              test "#parent returns 'de-Latn-DE-variant-a-ext' as the parent of 'de-Latn-DE-variant-a-ext-x-phonebk'" do
         | 
| 93 | 
            +
                tag = Tag::Rfc4646.new *%w(de Latn DE variant a-ext x-phonebk)
         | 
| 94 | 
            +
                assert_equal 'de-Latn-DE-variant-a-ext', tag.parent.to_s
         | 
| 95 | 
            +
              end
         | 
| 96 | 
            +
             | 
| 97 | 
            +
              test "#parent returns 'de-Latn-DE-variant' as the parent of 'de-Latn-DE-variant-a-ext'" do
         | 
| 98 | 
            +
                tag = Tag::Rfc4646.new *%w(de Latn DE variant a-ext)
         | 
| 99 | 
            +
                assert_equal 'de-Latn-DE-variant', tag.parent.to_s
         | 
| 100 | 
            +
              end
         | 
| 101 | 
            +
             | 
| 102 | 
            +
              test "#parent returns 'de-Latn-DE' as the parent of 'de-Latn-DE-variant'" do
         | 
| 103 | 
            +
                tag = Tag::Rfc4646.new *%w(de Latn DE variant)
         | 
| 104 | 
            +
                assert_equal 'de-Latn-DE', tag.parent.to_s
         | 
| 105 | 
            +
              end
         | 
| 106 | 
            +
             | 
| 107 | 
            +
              test "#parent returns 'de-Latn' as the parent of 'de-Latn-DE'" do
         | 
| 108 | 
            +
                tag = Tag::Rfc4646.new *%w(de Latn DE)
         | 
| 109 | 
            +
                assert_equal 'de-Latn', tag.parent.to_s
         | 
| 110 | 
            +
              end
         | 
| 111 | 
            +
             | 
| 112 | 
            +
              test "#parent returns 'de' as the parent of 'de-Latn'" do
         | 
| 113 | 
            +
                tag = Tag::Rfc4646.new *%w(de Latn)
         | 
| 114 | 
            +
                assert_equal 'de', tag.parent.to_s
         | 
| 115 | 
            +
              end
         | 
| 116 | 
            +
             | 
| 117 | 
            +
              # TODO RFC4647 says: "If no language tag matches the request, the "default" value is returned."
         | 
| 118 | 
            +
              # where should we set the default language?
         | 
| 119 | 
            +
              # test "#parent returns '' as the parent of 'de'" do
         | 
| 120 | 
            +
              #   tag = Tag::Rfc4646.new *%w(de)
         | 
| 121 | 
            +
              #   assert_equal '', tag.parent.to_s
         | 
| 122 | 
            +
              # end
         | 
| 123 | 
            +
             | 
| 124 | 
            +
              test "#parent returns an array of 5 parents for 'de-Latn-DE-variant-a-ext-x-phonebk-i-klingon'" do
         | 
| 125 | 
            +
                parents = %w(de-Latn-DE-variant-a-ext-x-phonebk-i-klingon
         | 
| 126 | 
            +
                             de-Latn-DE-variant-a-ext-x-phonebk
         | 
| 127 | 
            +
                             de-Latn-DE-variant-a-ext
         | 
| 128 | 
            +
                             de-Latn-DE-variant
         | 
| 129 | 
            +
                             de-Latn-DE
         | 
| 130 | 
            +
                             de-Latn
         | 
| 131 | 
            +
                             de)
         | 
| 132 | 
            +
                tag = Tag::Rfc4646.new *%w(de Latn DE variant a-ext x-phonebk i-klingon)
         | 
| 133 | 
            +
                assert_equal parents, tag.self_and_parents.map{|tag| tag.to_s}
         | 
| 134 | 
            +
              end
         | 
| 135 | 
            +
             | 
| 136 | 
            +
              test "returns an array of 5 parents for 'de-Latn-DE-variant-a-ext-x-phonebk-i-klingon'" do
         | 
| 137 | 
            +
                parents = %w(de-Latn-DE-variant-a-ext-x-phonebk-i-klingon
         | 
| 138 | 
            +
                             de-Latn-DE-variant-a-ext-x-phonebk
         | 
| 139 | 
            +
                             de-Latn-DE-variant-a-ext
         | 
| 140 | 
            +
                             de-Latn-DE-variant
         | 
| 141 | 
            +
                             de-Latn-DE
         | 
| 142 | 
            +
                             de-Latn
         | 
| 143 | 
            +
                             de)
         | 
| 144 | 
            +
                tag = Tag::Rfc4646.new *%w(de Latn DE variant a-ext x-phonebk i-klingon)
         | 
| 145 | 
            +
                assert_equal parents, tag.self_and_parents.map{|tag| tag.to_s}
         | 
| 146 | 
            +
              end
         | 
| 147 | 
            +
            end
         | 
| @@ -0,0 +1,35 @@ | |
| 1 | 
            +
            # encoding: utf-8
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require File.dirname(__FILE__) + '/../../test_helper.rb'
         | 
| 4 | 
            +
            require 'i18n/locale/tag'
         | 
| 5 | 
            +
            require 'i18n/locale/tag/simple'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            class I18nLocaleTagSimpleTest < Test::Unit::TestCase
         | 
| 8 | 
            +
              include I18n::Locale
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              test "returns 'de' as the language subtag in lowercase" do
         | 
| 11 | 
            +
                assert_equal %w(de Latn DE), Tag::Simple.new('de-Latn-DE').subtags
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              test "returns a formatted tag string from #to_s" do
         | 
| 15 | 
            +
                assert_equal 'de-Latn-DE', Tag::Simple.new('de-Latn-DE').to_s
         | 
| 16 | 
            +
              end
         | 
| 17 | 
            +
              
         | 
| 18 | 
            +
              test "returns an array containing the formatted subtags from #to_a" do
         | 
| 19 | 
            +
                assert_equal %w(de Latn DE), Tag::Simple.new('de-Latn-DE').to_a
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              # Tag inheritance
         | 
| 23 | 
            +
             | 
| 24 | 
            +
              test "#parent returns 'de-Latn' as the parent of 'de-Latn-DE'" do
         | 
| 25 | 
            +
                assert_equal 'de-Latn', Tag::Simple.new('de-Latn-DE').parent.to_s
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
              test "#parent returns 'de' as the parent of 'de-Latn'" do
         | 
| 29 | 
            +
                assert_equal 'de', Tag::Simple.new('de-Latn').parent.to_s
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
              test "#self_and_parents returns an array of 3 tags for 'de-Latn-DE'" do
         | 
| 33 | 
            +
                assert_equal %w(de-Latn-DE de-Latn de), Tag::Simple.new('de-Latn-DE').self_and_parents.map { |tag| tag.to_s}
         | 
| 34 | 
            +
              end
         | 
| 35 | 
            +
            end
         | 
    
        data/test/string_test.rb
    ADDED
    
    | @@ -0,0 +1,94 @@ | |
| 1 | 
            +
            # encoding: utf-8
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require File.expand_path(File.dirname(__FILE__) + '/test_helper')
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            # thanks to Masao's String extensions these should work the same in
         | 
| 6 | 
            +
            # Ruby 1.8 (patched) and Ruby 1.9 (native)
         | 
| 7 | 
            +
            # some tests taken from Masao's tests
         | 
| 8 | 
            +
            # http://github.com/mutoh/gettext/blob/edbbe1fa8238fa12c7f26f2418403015f0270e47/test/test_string.rb
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            class I18nStringTest < Test::Unit::TestCase
         | 
| 11 | 
            +
              define_method :"test: String interpolates a single argument" do
         | 
| 12 | 
            +
                assert_equal "Masao", "%s" % "Masao"
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              define_method :"test: String interpolates an array argument" do
         | 
| 16 | 
            +
                assert_equal "1 message", "%d %s" % [1, 'message']
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              define_method :"test: String interpolates a hash argument w/ named placeholders" do
         | 
| 20 | 
            +
                assert_equal "Masao Mutoh", "%{first} %{last}" % { :first => 'Masao', :last => 'Mutoh' }
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
              define_method :"test: String interpolates a hash argument w/ named placeholders (reverse order)" do
         | 
| 24 | 
            +
                assert_equal "Mutoh, Masao", "%{last}, %{first}" % { :first => 'Masao', :last => 'Mutoh' }
         | 
| 25 | 
            +
              end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
              define_method :"test: String interpolates named placeholders with sprintf syntax" do
         | 
| 28 | 
            +
                assert_equal "10, 43.4", "%<integer>d, %<float>.1f" % {:integer => 10, :float => 43.4}
         | 
| 29 | 
            +
              end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
              define_method :"test: String interpolates named placeholders with sprintf syntax, does not recurse" do
         | 
| 32 | 
            +
                assert_equal "%<not_translated>s", "%{msg}" % { :msg => '%<not_translated>s', :not_translated => 'should not happen' }
         | 
| 33 | 
            +
              end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
              define_method :"test: String interpolation does not replace anything when no placeholders are given" do
         | 
| 36 | 
            +
                assert_equal("aaa", "aaa" % {:num => 1})
         | 
| 37 | 
            +
                assert_equal("bbb", "bbb" % [1])
         | 
| 38 | 
            +
              end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
              define_method :"test: String interpolation sprintf behaviour equals Ruby 1.9 behaviour" do
         | 
| 41 | 
            +
                assert_equal("1", "%<num>d" % {:num => 1})
         | 
| 42 | 
            +
                assert_equal("0b1", "%<num>#b" % {:num => 1})
         | 
| 43 | 
            +
                assert_equal("foo", "%<msg>s" % {:msg => "foo"})
         | 
| 44 | 
            +
                assert_equal("1.000000", "%<num>f" % {:num => 1.0})
         | 
| 45 | 
            +
                assert_equal("  1", "%<num>3.0f" % {:num => 1.0})
         | 
| 46 | 
            +
                assert_equal("100.00", "%<num>2.2f" % {:num => 100.0})
         | 
| 47 | 
            +
                assert_equal("0x64", "%<num>#x" % {:num => 100.0})
         | 
| 48 | 
            +
                assert_raise(ArgumentError) { "%<num>,d" % {:num => 100} }
         | 
| 49 | 
            +
                assert_raise(ArgumentError) { "%<num>/d" % {:num => 100} }
         | 
| 50 | 
            +
              end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
              define_method :"test: String interpolation old-style sprintf still works" do
         | 
| 53 | 
            +
                assert_equal("foo 1.000000", "%s %f" % ["foo", 1.0])
         | 
| 54 | 
            +
              end
         | 
| 55 | 
            +
             | 
| 56 | 
            +
              define_method :"test: String interpolation raises an ArgumentError when the string has extra placeholders (Array)" do
         | 
| 57 | 
            +
                assert_raises(ArgumentError) do # Ruby 1.9 msg: "too few arguments"
         | 
| 58 | 
            +
                  "%s %s" % %w(Masao)
         | 
| 59 | 
            +
                end
         | 
| 60 | 
            +
              end
         | 
| 61 | 
            +
             | 
| 62 | 
            +
              define_method :"test: String interpolation raises a KeyError when the string has extra placeholders (Hash)" do
         | 
| 63 | 
            +
                assert_raises(KeyError) do # Ruby 1.9 msg: "key not found"
         | 
| 64 | 
            +
                  "%{first} %{last}" % { :first => 'Masao' }
         | 
| 65 | 
            +
                end
         | 
| 66 | 
            +
              end
         | 
| 67 | 
            +
             | 
| 68 | 
            +
              define_method :"test: String interpolation does not raise when passed extra values (Array)" do
         | 
| 69 | 
            +
                assert_nothing_raised do
         | 
| 70 | 
            +
                  assert_equal "Masao", "%s" % %w(Masao Mutoh)
         | 
| 71 | 
            +
                end
         | 
| 72 | 
            +
              end
         | 
| 73 | 
            +
             | 
| 74 | 
            +
              define_method :"test: String interpolation does not raise when passed extra values (Hash)" do
         | 
| 75 | 
            +
                assert_nothing_raised do
         | 
| 76 | 
            +
                  assert_equal "Masao Mutoh", "%{first} %{last}" % { :first => 'Masao', :last => 'Mutoh', :salutation => 'Mr.' }
         | 
| 77 | 
            +
                end
         | 
| 78 | 
            +
              end
         | 
| 79 | 
            +
             | 
| 80 | 
            +
              define_method :"test: % acts as escape character in String interpolation" do
         | 
| 81 | 
            +
                assert_equal "%{first}", "%%{first}" % { :first => 'Masao' }
         | 
| 82 | 
            +
                assert_equal("% 1", "%% %<num>d" % {:num => 1.0})
         | 
| 83 | 
            +
                assert_equal("%{num} %<num>d", "%%{num} %%<num>d" % {:num => 1})
         | 
| 84 | 
            +
              end
         | 
| 85 | 
            +
             | 
| 86 | 
            +
              def test_sprintf_mix_unformatted_and_formatted_named_placeholders
         | 
| 87 | 
            +
                assert_equal("foo 1.000000", "%{name} %<num>f" % {:name => "foo", :num => 1.0})
         | 
| 88 | 
            +
              end
         | 
| 89 | 
            +
              
         | 
| 90 | 
            +
              def test_string_interpolation_raises_an_argument_error_when_mixing_named_and_unnamed_placeholders
         | 
| 91 | 
            +
                assert_raises(ArgumentError) { "%{name} %f" % [1.0] }
         | 
| 92 | 
            +
                assert_raises(ArgumentError) { "%{name} %f" % [1.0, 2.0] }
         | 
| 93 | 
            +
              end
         | 
| 94 | 
            +
            end
         | 
    
        data/test/test_helper.rb
    ADDED
    
    | @@ -0,0 +1,71 @@ | |
| 1 | 
            +
            # encoding: utf-8
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            $:.unshift "lib"
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            require 'rubygems'
         | 
| 6 | 
            +
            require 'test/unit'
         | 
| 7 | 
            +
            require 'mocha'
         | 
| 8 | 
            +
            require 'i18n'
         | 
| 9 | 
            +
            require 'time'
         | 
| 10 | 
            +
            require 'yaml'
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            require File.dirname(__FILE__) + '/with_options'
         | 
| 13 | 
            +
            require File.dirname(__FILE__) + '/backend/simple/setup'
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            Dir[File.dirname(__FILE__) + '/api/**/*.rb'].each do |filename|
         | 
| 16 | 
            +
              require filename
         | 
| 17 | 
            +
            end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            $KCODE = 'u' unless RUBY_VERSION >= '1.9'
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            class Test::Unit::TestCase
         | 
| 22 | 
            +
              def self.test(name, &block)
         | 
| 23 | 
            +
                define_method("test: " + name, &block)
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
              def euc_jp(string)
         | 
| 27 | 
            +
                string.encode!(Encoding::EUC_JP)
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
              
         | 
| 30 | 
            +
              def locales_dir
         | 
| 31 | 
            +
                File.dirname(__FILE__) + '/fixtures/locales'
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
              def backend_store_translations(*args)
         | 
| 35 | 
            +
                I18n.backend.store_translations(*args)
         | 
| 36 | 
            +
              end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
              def backend_get_translations
         | 
| 39 | 
            +
                I18n.backend.instance_variable_get :@translations
         | 
| 40 | 
            +
              end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
              def date
         | 
| 43 | 
            +
                Date.new(2008, 3, 1)
         | 
| 44 | 
            +
              end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
              def morning_datetime
         | 
| 47 | 
            +
                DateTime.new(2008, 3, 1, 6)
         | 
| 48 | 
            +
              end
         | 
| 49 | 
            +
              alias :datetime :morning_datetime
         | 
| 50 | 
            +
             | 
| 51 | 
            +
              def evening_datetime
         | 
| 52 | 
            +
                DateTime.new(2008, 3, 1, 18)
         | 
| 53 | 
            +
              end
         | 
| 54 | 
            +
             | 
| 55 | 
            +
              def morning_time
         | 
| 56 | 
            +
                Time.parse('2008-03-01 6:00 UTC')
         | 
| 57 | 
            +
              end
         | 
| 58 | 
            +
              alias :time :morning_time
         | 
| 59 | 
            +
             | 
| 60 | 
            +
              def evening_time
         | 
| 61 | 
            +
                Time.parse('2008-03-01 18:00 UTC')
         | 
| 62 | 
            +
              end
         | 
| 63 | 
            +
            end
         | 
| 64 | 
            +
             | 
| 65 | 
            +
            class Object
         | 
| 66 | 
            +
              def meta_class
         | 
| 67 | 
            +
                class << self; self; end
         | 
| 68 | 
            +
              end
         | 
| 69 | 
            +
            end
         | 
| 70 | 
            +
             | 
| 71 | 
            +
             | 
| @@ -0,0 +1,34 @@ | |
| 1 | 
            +
            # encoding: utf-8
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            # this is only here so we can test I18n works nicely with ActiveSupports
         | 
| 4 | 
            +
            # with_options. Maybe we can just remove it?
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            class Object
         | 
| 7 | 
            +
              def with_options(options)
         | 
| 8 | 
            +
                yield ActiveSupport::OptionMerger.new(self, options)
         | 
| 9 | 
            +
              end
         | 
| 10 | 
            +
            end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            module ActiveSupport
         | 
| 13 | 
            +
              class OptionMerger #:nodoc:
         | 
| 14 | 
            +
                instance_methods.each do |method|
         | 
| 15 | 
            +
                  undef_method(method) if method !~ /^(__|instance_eval|class|object_id)/
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                def initialize(context, options)
         | 
| 19 | 
            +
                  @context, @options = context, options
         | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                private
         | 
| 23 | 
            +
                  def method_missing(method, *arguments, &block)
         | 
| 24 | 
            +
                    if arguments.last.is_a?(Proc)
         | 
| 25 | 
            +
                      proc = arguments.pop
         | 
| 26 | 
            +
                      arguments << lambda { |*args| @options.deep_merge(proc.call(*args)) }
         | 
| 27 | 
            +
                    else
         | 
| 28 | 
            +
                      arguments << (arguments.last.respond_to?(:to_hash) ? @options.deep_merge(arguments.pop) : @options.dup)
         | 
| 29 | 
            +
                    end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                    @context.__send__(method, *arguments, &block)
         | 
| 32 | 
            +
                  end
         | 
| 33 | 
            +
              end
         | 
| 34 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,151 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification 
         | 
| 2 | 
            +
            name: pepe-i18n
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            +
              version: 0.2.0
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors: 
         | 
| 7 | 
            +
            - Sven Fuchs
         | 
| 8 | 
            +
            - Joshua Harvey
         | 
| 9 | 
            +
            - Matt Aimonetti
         | 
| 10 | 
            +
            - Stephan Soller
         | 
| 11 | 
            +
            - Saimon Moore
         | 
| 12 | 
            +
            autorequire: 
         | 
| 13 | 
            +
            bindir: bin
         | 
| 14 | 
            +
            cert_chain: []
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            date: 2009-09-09 00:00:00 -07:00
         | 
| 17 | 
            +
            default_executable: 
         | 
| 18 | 
            +
            dependencies: []
         | 
| 19 | 
            +
             | 
| 20 | 
            +
            description: Add Internationalization support to your Ruby application.
         | 
| 21 | 
            +
            email: rails-i18n@googlegroups.com
         | 
| 22 | 
            +
            executables: []
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            extensions: []
         | 
| 25 | 
            +
             | 
| 26 | 
            +
            extra_rdoc_files: 
         | 
| 27 | 
            +
            - README.textile
         | 
| 28 | 
            +
            files: 
         | 
| 29 | 
            +
            - CHANGELOG.textile
         | 
| 30 | 
            +
            - MIT-LICENSE
         | 
| 31 | 
            +
            - README.textile
         | 
| 32 | 
            +
            - Rakefile
         | 
| 33 | 
            +
            - VERSION
         | 
| 34 | 
            +
            - lib/i18n.rb
         | 
| 35 | 
            +
            - lib/i18n/backend/base.rb
         | 
| 36 | 
            +
            - lib/i18n/backend/cache.rb
         | 
| 37 | 
            +
            - lib/i18n/backend/chain.rb
         | 
| 38 | 
            +
            - lib/i18n/backend/fallbacks.rb
         | 
| 39 | 
            +
            - lib/i18n/backend/gettext.rb
         | 
| 40 | 
            +
            - lib/i18n/backend/pluralization.rb
         | 
| 41 | 
            +
            - lib/i18n/backend/simple.rb
         | 
| 42 | 
            +
            - lib/i18n/exceptions.rb
         | 
| 43 | 
            +
            - lib/i18n/gettext.rb
         | 
| 44 | 
            +
            - lib/i18n/helpers/gettext.rb
         | 
| 45 | 
            +
            - lib/i18n/locale/fallbacks.rb
         | 
| 46 | 
            +
            - lib/i18n/locale/tag.rb
         | 
| 47 | 
            +
            - lib/i18n/locale/tag/parents.rb
         | 
| 48 | 
            +
            - lib/i18n/locale/tag/rfc4646.rb
         | 
| 49 | 
            +
            - lib/i18n/locale/tag/simple.rb
         | 
| 50 | 
            +
            - lib/i18n/string.rb
         | 
| 51 | 
            +
            - test/all.rb
         | 
| 52 | 
            +
            - test/api/basics.rb
         | 
| 53 | 
            +
            - test/api/interpolation.rb
         | 
| 54 | 
            +
            - test/api/lambda.rb
         | 
| 55 | 
            +
            - test/api/link.rb
         | 
| 56 | 
            +
            - test/api/localization/date.rb
         | 
| 57 | 
            +
            - test/api/localization/date_time.rb
         | 
| 58 | 
            +
            - test/api/localization/lambda.rb
         | 
| 59 | 
            +
            - test/api/localization/time.rb
         | 
| 60 | 
            +
            - test/api/pluralization.rb
         | 
| 61 | 
            +
            - test/api/translation.rb
         | 
| 62 | 
            +
            - test/backend/cache/cache_test.rb
         | 
| 63 | 
            +
            - test/backend/chain/api_test.rb
         | 
| 64 | 
            +
            - test/backend/chain/chain_test.rb
         | 
| 65 | 
            +
            - test/backend/fallbacks/api_test.rb
         | 
| 66 | 
            +
            - test/backend/fallbacks/fallbacks_test.rb
         | 
| 67 | 
            +
            - test/backend/pluralization/api_test.rb
         | 
| 68 | 
            +
            - test/backend/pluralization/pluralization_test.rb
         | 
| 69 | 
            +
            - test/backend/simple/all.rb
         | 
| 70 | 
            +
            - test/backend/simple/api_test.rb
         | 
| 71 | 
            +
            - test/backend/simple/lookup_test.rb
         | 
| 72 | 
            +
            - test/backend/simple/setup.rb
         | 
| 73 | 
            +
            - test/backend/simple/translations_test.rb
         | 
| 74 | 
            +
            - test/fixtures/locales/de.po
         | 
| 75 | 
            +
            - test/fixtures/locales/en.rb
         | 
| 76 | 
            +
            - test/fixtures/locales/en.yml
         | 
| 77 | 
            +
            - test/fixtures/locales/plurals.rb
         | 
| 78 | 
            +
            - test/gettext/api_test.rb
         | 
| 79 | 
            +
            - test/gettext/backend_test.rb
         | 
| 80 | 
            +
            - test/i18n_exceptions_test.rb
         | 
| 81 | 
            +
            - test/i18n_load_path_test.rb
         | 
| 82 | 
            +
            - test/i18n_test.rb
         | 
| 83 | 
            +
            - test/locale/fallbacks_test.rb
         | 
| 84 | 
            +
            - test/locale/tag/rfc4646_test.rb
         | 
| 85 | 
            +
            - test/locale/tag/simple_test.rb
         | 
| 86 | 
            +
            - test/string_test.rb
         | 
| 87 | 
            +
            - test/test_helper.rb
         | 
| 88 | 
            +
            - test/with_options.rb
         | 
| 89 | 
            +
            has_rdoc: false
         | 
| 90 | 
            +
            homepage: http://rails-i18n.org
         | 
| 91 | 
            +
            post_install_message: 
         | 
| 92 | 
            +
            rdoc_options: 
         | 
| 93 | 
            +
            - --charset=UTF-8
         | 
| 94 | 
            +
            require_paths: 
         | 
| 95 | 
            +
            - lib
         | 
| 96 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement 
         | 
| 97 | 
            +
              requirements: 
         | 
| 98 | 
            +
              - - ">="
         | 
| 99 | 
            +
                - !ruby/object:Gem::Version 
         | 
| 100 | 
            +
                  version: "0"
         | 
| 101 | 
            +
              version: 
         | 
| 102 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement 
         | 
| 103 | 
            +
              requirements: 
         | 
| 104 | 
            +
              - - ">="
         | 
| 105 | 
            +
                - !ruby/object:Gem::Version 
         | 
| 106 | 
            +
                  version: "0"
         | 
| 107 | 
            +
              version: 
         | 
| 108 | 
            +
            requirements: []
         | 
| 109 | 
            +
             | 
| 110 | 
            +
            rubyforge_project: i18n
         | 
| 111 | 
            +
            rubygems_version: 1.2.0
         | 
| 112 | 
            +
            signing_key: 
         | 
| 113 | 
            +
            specification_version: 3
         | 
| 114 | 
            +
            summary: New wave Internationalization support for Ruby
         | 
| 115 | 
            +
            test_files: 
         | 
| 116 | 
            +
            - test/all.rb
         | 
| 117 | 
            +
            - test/api/basics.rb
         | 
| 118 | 
            +
            - test/api/interpolation.rb
         | 
| 119 | 
            +
            - test/api/lambda.rb
         | 
| 120 | 
            +
            - test/api/link.rb
         | 
| 121 | 
            +
            - test/api/localization/date.rb
         | 
| 122 | 
            +
            - test/api/localization/date_time.rb
         | 
| 123 | 
            +
            - test/api/localization/lambda.rb
         | 
| 124 | 
            +
            - test/api/localization/time.rb
         | 
| 125 | 
            +
            - test/api/pluralization.rb
         | 
| 126 | 
            +
            - test/api/translation.rb
         | 
| 127 | 
            +
            - test/backend/cache/cache_test.rb
         | 
| 128 | 
            +
            - test/backend/chain/api_test.rb
         | 
| 129 | 
            +
            - test/backend/chain/chain_test.rb
         | 
| 130 | 
            +
            - test/backend/fallbacks/api_test.rb
         | 
| 131 | 
            +
            - test/backend/fallbacks/fallbacks_test.rb
         | 
| 132 | 
            +
            - test/backend/pluralization/api_test.rb
         | 
| 133 | 
            +
            - test/backend/pluralization/pluralization_test.rb
         | 
| 134 | 
            +
            - test/backend/simple/all.rb
         | 
| 135 | 
            +
            - test/backend/simple/api_test.rb
         | 
| 136 | 
            +
            - test/backend/simple/lookup_test.rb
         | 
| 137 | 
            +
            - test/backend/simple/setup.rb
         | 
| 138 | 
            +
            - test/backend/simple/translations_test.rb
         | 
| 139 | 
            +
            - test/fixtures/locales/en.rb
         | 
| 140 | 
            +
            - test/fixtures/locales/plurals.rb
         | 
| 141 | 
            +
            - test/gettext/api_test.rb
         | 
| 142 | 
            +
            - test/gettext/backend_test.rb
         | 
| 143 | 
            +
            - test/i18n_exceptions_test.rb
         | 
| 144 | 
            +
            - test/i18n_load_path_test.rb
         | 
| 145 | 
            +
            - test/i18n_test.rb
         | 
| 146 | 
            +
            - test/locale/fallbacks_test.rb
         | 
| 147 | 
            +
            - test/locale/tag/rfc4646_test.rb
         | 
| 148 | 
            +
            - test/locale/tag/simple_test.rb
         | 
| 149 | 
            +
            - test/string_test.rb
         | 
| 150 | 
            +
            - test/test_helper.rb
         | 
| 151 | 
            +
            - test/with_options.rb
         |