diff options
author | Sven Fuchs <svenfuchs@artweb-design.de> | 2009-02-27 17:07:06 +0100 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2009-02-27 17:15:15 +0100 |
commit | 943d64b1c857944666bff2572857abe866615274 (patch) | |
tree | 6172d15c3252ffe8b86a7e071f454fecdb661bdb /activesupport | |
parent | 77b0994c7835610982d708ce7ce5cd95e6e99e5a (diff) | |
download | rails-943d64b1c857944666bff2572857abe866615274.tar.gz rails-943d64b1c857944666bff2572857abe866615274.tar.bz2 rails-943d64b1c857944666bff2572857abe866615274.zip |
Vendorize i18n 0.1.3 gem (fixes issues with incompatible character encodings in Ruby 1.9) (Akira Matsuda) [#2038 state:committed]
Signed-off-by: David Heinemeier Hansson <david@loudthinking.com>
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/CHANGELOG | 2 | ||||
-rw-r--r-- | activesupport/lib/active_support/vendor.rb | 4 | ||||
-rw-r--r-- | activesupport/lib/active_support/vendor/i18n-0.1.1/.gitignore | 3 | ||||
-rwxr-xr-x | activesupport/lib/active_support/vendor/i18n-0.1.3/MIT-LICENSE (renamed from activesupport/lib/active_support/vendor/i18n-0.1.1/MIT-LICENSE) | 0 | ||||
-rw-r--r-- | activesupport/lib/active_support/vendor/i18n-0.1.3/README.textile (renamed from activesupport/lib/active_support/vendor/i18n-0.1.1/README.textile) | 0 | ||||
-rw-r--r-- | activesupport/lib/active_support/vendor/i18n-0.1.3/Rakefile (renamed from activesupport/lib/active_support/vendor/i18n-0.1.1/Rakefile) | 0 | ||||
-rw-r--r-- | activesupport/lib/active_support/vendor/i18n-0.1.3/i18n.gemspec (renamed from activesupport/lib/active_support/vendor/i18n-0.1.1/i18n.gemspec) | 4 | ||||
-rwxr-xr-x | activesupport/lib/active_support/vendor/i18n-0.1.3/lib/i18n.rb (renamed from activesupport/lib/active_support/vendor/i18n-0.1.1/lib/i18n.rb) | 0 | ||||
-rw-r--r-- | activesupport/lib/active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb (renamed from activesupport/lib/active_support/vendor/i18n-0.1.1/lib/i18n/backend/simple.rb) | 10 | ||||
-rw-r--r-- | activesupport/lib/active_support/vendor/i18n-0.1.3/lib/i18n/exceptions.rb (renamed from activesupport/lib/active_support/vendor/i18n-0.1.1/lib/i18n/exceptions.rb) | 0 | ||||
-rw-r--r-- | activesupport/lib/active_support/vendor/i18n-0.1.3/test/all.rb (renamed from activesupport/lib/active_support/vendor/i18n-0.1.1/test/all.rb) | 0 | ||||
-rw-r--r-- | activesupport/lib/active_support/vendor/i18n-0.1.3/test/i18n_exceptions_test.rb (renamed from activesupport/lib/active_support/vendor/i18n-0.1.1/test/i18n_exceptions_test.rb) | 0 | ||||
-rw-r--r-- | activesupport/lib/active_support/vendor/i18n-0.1.3/test/i18n_test.rb (renamed from activesupport/lib/active_support/vendor/i18n-0.1.1/test/i18n_test.rb) | 0 | ||||
-rw-r--r-- | activesupport/lib/active_support/vendor/i18n-0.1.3/test/locale/en.rb (renamed from activesupport/lib/active_support/vendor/i18n-0.1.1/test/locale/en.rb) | 0 | ||||
-rw-r--r-- | activesupport/lib/active_support/vendor/i18n-0.1.3/test/locale/en.yml (renamed from activesupport/lib/active_support/vendor/i18n-0.1.1/test/locale/en.yml) | 0 | ||||
-rw-r--r-- | activesupport/lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb (renamed from activesupport/lib/active_support/vendor/i18n-0.1.1/test/simple_backend_test.rb) | 46 |
16 files changed, 52 insertions, 17 deletions
diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG index 5d9b77bbf5..c0f24a103d 100644 --- a/activesupport/CHANGELOG +++ b/activesupport/CHANGELOG @@ -1,5 +1,7 @@ *2.3.1 [RC2] (February 27th, 2009)* +* Vendorize i18n 0.1.3 gem (fixes issues with incompatible character encodings in Ruby 1.9) #2038 [Akira Matsuda] + * Update bundled memcache-client from 1.5.0.5 to 1.6.4.99. See http://www.mikeperham.com/2009/02/15/memcache-client-performance/ [Mike Perham] * Ruby 1.9.1p0 fix: URI.unescape can decode multibyte chars. #2033 [MOROHASHI Kyosuke] diff --git a/activesupport/lib/active_support/vendor.rb b/activesupport/lib/active_support/vendor.rb index 39da70a9f3..28852e65c8 100644 --- a/activesupport/lib/active_support/vendor.rb +++ b/activesupport/lib/active_support/vendor.rb @@ -22,8 +22,8 @@ end # TODO I18n gem has not been released yet # begin -# gem 'i18n', '~> 0.1.1' +# gem 'i18n', '~> 0.1.3' # rescue Gem::LoadError - $:.unshift "#{File.dirname(__FILE__)}/vendor/i18n-0.1.1/lib" + $:.unshift "#{File.dirname(__FILE__)}/vendor/i18n-0.1.3/lib" require 'i18n' # end diff --git a/activesupport/lib/active_support/vendor/i18n-0.1.1/.gitignore b/activesupport/lib/active_support/vendor/i18n-0.1.1/.gitignore deleted file mode 100644 index 0f41a39f89..0000000000 --- a/activesupport/lib/active_support/vendor/i18n-0.1.1/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -.DS_Store -test/rails/fixtures -doc diff --git a/activesupport/lib/active_support/vendor/i18n-0.1.1/MIT-LICENSE b/activesupport/lib/active_support/vendor/i18n-0.1.3/MIT-LICENSE index ed8e9ee66d..ed8e9ee66d 100755 --- a/activesupport/lib/active_support/vendor/i18n-0.1.1/MIT-LICENSE +++ b/activesupport/lib/active_support/vendor/i18n-0.1.3/MIT-LICENSE diff --git a/activesupport/lib/active_support/vendor/i18n-0.1.1/README.textile b/activesupport/lib/active_support/vendor/i18n-0.1.3/README.textile index a07fc8426d..a07fc8426d 100644 --- a/activesupport/lib/active_support/vendor/i18n-0.1.1/README.textile +++ b/activesupport/lib/active_support/vendor/i18n-0.1.3/README.textile diff --git a/activesupport/lib/active_support/vendor/i18n-0.1.1/Rakefile b/activesupport/lib/active_support/vendor/i18n-0.1.3/Rakefile index 2164e13e69..2164e13e69 100644 --- a/activesupport/lib/active_support/vendor/i18n-0.1.1/Rakefile +++ b/activesupport/lib/active_support/vendor/i18n-0.1.3/Rakefile diff --git a/activesupport/lib/active_support/vendor/i18n-0.1.1/i18n.gemspec b/activesupport/lib/active_support/vendor/i18n-0.1.3/i18n.gemspec index 14294606bd..f102689a6f 100644 --- a/activesupport/lib/active_support/vendor/i18n-0.1.1/i18n.gemspec +++ b/activesupport/lib/active_support/vendor/i18n-0.1.3/i18n.gemspec @@ -1,7 +1,7 @@ Gem::Specification.new do |s| s.name = "i18n" - s.version = "0.1.1" - s.date = "2008-10-26" + s.version = "0.1.3" + s.date = "2009-01-09" s.summary = "Internationalization support for Ruby" s.email = "rails-i18n@googlegroups.com" s.homepage = "http://rails-i18n.org" diff --git a/activesupport/lib/active_support/vendor/i18n-0.1.1/lib/i18n.rb b/activesupport/lib/active_support/vendor/i18n-0.1.3/lib/i18n.rb index 76361bed90..76361bed90 100755 --- a/activesupport/lib/active_support/vendor/i18n-0.1.1/lib/i18n.rb +++ b/activesupport/lib/active_support/vendor/i18n-0.1.3/lib/i18n.rb diff --git a/activesupport/lib/active_support/vendor/i18n-0.1.1/lib/i18n/backend/simple.rb b/activesupport/lib/active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb index b54164d496..c09acd7d2d 100644 --- a/activesupport/lib/active_support/vendor/i18n-0.1.1/lib/i18n/backend/simple.rb +++ b/activesupport/lib/active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb @@ -151,12 +151,7 @@ module I18n def interpolate(locale, string, values = {}) return string unless string.is_a?(String) - if string.respond_to?(:force_encoding) - original_encoding = string.encoding - string.force_encoding(Encoding::BINARY) - end - - result = string.gsub(MATCH) do + string.gsub(MATCH) do escaped, pattern, key = $1, $2, $2.to_sym if escaped @@ -169,9 +164,6 @@ module I18n values[key].to_s end end - - result.force_encoding(original_encoding) if original_encoding - result end # Loads a single translations file by delegating to #load_rb or diff --git a/activesupport/lib/active_support/vendor/i18n-0.1.1/lib/i18n/exceptions.rb b/activesupport/lib/active_support/vendor/i18n-0.1.3/lib/i18n/exceptions.rb index b5cea7acb4..b5cea7acb4 100644 --- a/activesupport/lib/active_support/vendor/i18n-0.1.1/lib/i18n/exceptions.rb +++ b/activesupport/lib/active_support/vendor/i18n-0.1.3/lib/i18n/exceptions.rb diff --git a/activesupport/lib/active_support/vendor/i18n-0.1.1/test/all.rb b/activesupport/lib/active_support/vendor/i18n-0.1.3/test/all.rb index 353712da49..353712da49 100644 --- a/activesupport/lib/active_support/vendor/i18n-0.1.1/test/all.rb +++ b/activesupport/lib/active_support/vendor/i18n-0.1.3/test/all.rb diff --git a/activesupport/lib/active_support/vendor/i18n-0.1.1/test/i18n_exceptions_test.rb b/activesupport/lib/active_support/vendor/i18n-0.1.3/test/i18n_exceptions_test.rb index dfcba6901f..dfcba6901f 100644 --- a/activesupport/lib/active_support/vendor/i18n-0.1.1/test/i18n_exceptions_test.rb +++ b/activesupport/lib/active_support/vendor/i18n-0.1.3/test/i18n_exceptions_test.rb diff --git a/activesupport/lib/active_support/vendor/i18n-0.1.1/test/i18n_test.rb b/activesupport/lib/active_support/vendor/i18n-0.1.3/test/i18n_test.rb index bbb35ec809..bbb35ec809 100644 --- a/activesupport/lib/active_support/vendor/i18n-0.1.1/test/i18n_test.rb +++ b/activesupport/lib/active_support/vendor/i18n-0.1.3/test/i18n_test.rb diff --git a/activesupport/lib/active_support/vendor/i18n-0.1.1/test/locale/en.rb b/activesupport/lib/active_support/vendor/i18n-0.1.3/test/locale/en.rb index 6044ce10d9..6044ce10d9 100644 --- a/activesupport/lib/active_support/vendor/i18n-0.1.1/test/locale/en.rb +++ b/activesupport/lib/active_support/vendor/i18n-0.1.3/test/locale/en.rb diff --git a/activesupport/lib/active_support/vendor/i18n-0.1.1/test/locale/en.yml b/activesupport/lib/active_support/vendor/i18n-0.1.3/test/locale/en.yml index 0b298c9c0e..0b298c9c0e 100644 --- a/activesupport/lib/active_support/vendor/i18n-0.1.1/test/locale/en.yml +++ b/activesupport/lib/active_support/vendor/i18n-0.1.3/test/locale/en.yml diff --git a/activesupport/lib/active_support/vendor/i18n-0.1.1/test/simple_backend_test.rb b/activesupport/lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb index 8ba7036abf..7b7b137579 100644 --- a/activesupport/lib/active_support/vendor/i18n-0.1.1/test/simple_backend_test.rb +++ b/activesupport/lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb @@ -253,6 +253,32 @@ class I18nSimpleBackendInterpolateTest < Test::Unit::TestCase assert_equal 'Häi David!', @backend.send(:interpolate, nil, 'Häi {{name}}!', :name => 'David') end + def test_interpolate_given_an_unicode_value_hash_interpolates_to_the_string + assert_equal 'Hi ゆきひろ!', @backend.send(:interpolate, nil, 'Hi {{name}}!', :name => 'ゆきひろ') + end + + def test_interpolate_given_an_unicode_value_hash_interpolates_into_unicode_string + assert_equal 'こんにちは、ゆきひろさん!', @backend.send(:interpolate, nil, 'こんにちは、{{name}}さん!', :name => 'ゆきひろ') + end + + if Kernel.const_defined?(:Encoding) + def test_interpolate_given_a_non_unicode_multibyte_value_hash_interpolates_into_a_string_with_the_same_encoding + assert_equal euc_jp('Hi ゆきひろ!'), @backend.send(:interpolate, nil, 'Hi {{name}}!', :name => euc_jp('ゆきひろ')) + end + + def test_interpolate_given_an_unicode_value_hash_into_a_non_unicode_multibyte_string_raises_encoding_compatibility_error + assert_raises(Encoding::CompatibilityError) do + @backend.send(:interpolate, nil, euc_jp('こんにちは、{{name}}さん!'), :name => 'ゆきひろ') + end + end + + def test_interpolate_given_a_non_unicode_multibyte_value_hash_into_an_unicode_string_raises_encoding_compatibility_error + assert_raises(Encoding::CompatibilityError) do + @backend.send(:interpolate, nil, 'こんにちは、{{name}}さん!', :name => euc_jp('ゆきひろ')) + end + end + end + def test_interpolate_given_nil_as_a_string_returns_nil assert_nil @backend.send(:interpolate, nil, nil, :name => 'David') end @@ -272,6 +298,12 @@ class I18nSimpleBackendInterpolateTest < Test::Unit::TestCase def test_interpolate_given_a_string_containing_a_reserved_key_raises_reserved_interpolation_key assert_raises(I18n::ReservedInterpolationKey) { @backend.send(:interpolate, nil, '{{default}}', {:default => nil}) } end + + private + + def euc_jp(string) + string.encode!(Encoding::EUC_JP) + end end class I18nSimpleBackendLocalizeDateTest < Test::Unit::TestCase @@ -485,6 +517,10 @@ end class I18nSimpleBackendLoadPathTest < Test::Unit::TestCase include I18nSimpleBackendTestSetup + def teardown + I18n.load_path = [] + end + def test_nested_load_paths_do_not_break_locale_loading @backend = I18n::Backend::Simple.new I18n.load_path = [[File.dirname(__FILE__) + '/locale/en.yml']] @@ -492,6 +528,14 @@ class I18nSimpleBackendLoadPathTest < Test::Unit::TestCase assert_nothing_raised { @backend.send :init_translations } assert_not_nil backend_get_translations end + + def test_adding_arrays_of_filenames_to_load_path_do_not_break_locale_loading + @backend = I18n::Backend::Simple.new + I18n.load_path << Dir[File.dirname(__FILE__) + '/locale/*.{rb,yml}'] + assert_nil backend_get_translations + assert_nothing_raised { @backend.send :init_translations } + assert_not_nil backend_get_translations + end end class I18nSimpleBackendReloadTranslationsTest < Test::Unit::TestCase @@ -521,4 +565,4 @@ class I18nSimpleBackendReloadTranslationsTest < Test::Unit::TestCase @backend.reload! assert_equal @backend.initialized?, false end -end
\ No newline at end of file +end |