From 4960a6bdaf7cf58bf3dfe340b50735b87ec9df96 Mon Sep 17 00:00:00 2001 From: Nikos Dimitrakopoulos Date: Thu, 10 Nov 2011 13:09:38 +0200 Subject: [PATCH 001/145] Added Gettext::Helpers.N_ method that can be used to help the gettext parser. --- lib/i18n/gettext/helpers.rb | 9 +++++++++ test/gettext/api_test.rb | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/lib/i18n/gettext/helpers.rb b/lib/i18n/gettext/helpers.rb index ea07d052..c97fd349 100644 --- a/lib/i18n/gettext/helpers.rb +++ b/lib/i18n/gettext/helpers.rb @@ -7,6 +7,15 @@ module Gettext # # include I18n::Gettext::Helpers module Helpers + # Makes dynamic translation messages readable for the gettext parser. + # _(fruit) cannot be understood by the gettext parser. To help the parser find all your translations, + # you can add fruit = N_("Apple") which does not translate, but tells the parser: "Apple" needs translation. + # * msgid: the message id. + # * Returns: msgid. + def N_(msgsid) + msgsid + end + def gettext(msgid, options = {}) I18n.t(msgid, { :default => msgid, :separator => '|' }.merge(options)) end diff --git a/test/gettext/api_test.rb b/test/gettext/api_test.rb index 947b5a23..7d1e0e1f 100644 --- a/test/gettext/api_test.rb +++ b/test/gettext/api_test.rb @@ -17,6 +17,13 @@ def setup }, :separator => '|' end + # N_ + def test_N_returns_original_msg + assert_equal 'foo|bar', N_('foo|bar') + I18n.locale = :de + assert_equal 'Hi Gettext!', N_('Hi Gettext!') + end + # gettext def test_gettext_uses_msg_as_default assert_equal 'Hi Gettext!', _('Hi Gettext!') From d311ce434aeee72e95d0158759c45a91410b4e67 Mon Sep 17 00:00:00 2001 From: Mike Ragalie Date: Sun, 1 Apr 2012 13:57:43 -0700 Subject: [PATCH 002/145] Cache#_fetch correctly handles cached 'false' --- lib/i18n/backend/cache.rb | 3 ++- test/backend/cache_test.rb | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/i18n/backend/cache.rb b/lib/i18n/backend/cache.rb index 67573418..a0292b53 100644 --- a/lib/i18n/backend/cache.rb +++ b/lib/i18n/backend/cache.rb @@ -76,7 +76,8 @@ def fetch(cache_key, &block) end def _fetch(cache_key, &block) - result = I18n.cache_store.read(cache_key) and return result + result = I18n.cache_store.read(cache_key) + return result unless result.nil? result = catch(:exception, &block) I18n.cache_store.write(cache_key, result) unless result.is_a?(Proc) result diff --git a/test/backend/cache_test.rb b/test/backend/cache_test.rb index 39df10d4..de212aab 100644 --- a/test/backend/cache_test.rb +++ b/test/backend/cache_test.rb @@ -36,6 +36,12 @@ def teardown assert_equal 'Bar', I18n.t(:bar) end + test "translate returns a cached false response" do + I18n.backend.expects(:lookup).never + I18n.cache_store.expects(:read).returns(false) + assert_equal false, I18n.t(:foo) + end + test "still raises MissingTranslationData but also caches it" do assert_raise(I18n::MissingTranslationData) { I18n.t(:missing, :raise => true) } assert_raise(I18n::MissingTranslationData) { I18n.t(:missing, :raise => true) } From f62e641e5f14ac7a9b59764e1d155169c30378d1 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Sat, 11 May 2013 11:14:01 +0900 Subject: [PATCH 003/145] chmod -x lib/i18n.rb --- lib/i18n.rb | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 lib/i18n.rb diff --git a/lib/i18n.rb b/lib/i18n.rb old mode 100755 new mode 100644 From 913e40e44ca301c0449299419b3ffda2a94ad520 Mon Sep 17 00:00:00 2001 From: Bogdan Gusiev Date: Sat, 31 Aug 2013 18:26:49 +0300 Subject: [PATCH 004/145] Fix I18n.interpolate when ActiveSupport::SafeBuffer passed as argument --- lib/i18n/interpolate/ruby.rb | 2 +- test/i18n/interpolate_test.rb | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/i18n/interpolate/ruby.rb b/lib/i18n/interpolate/ruby.rb index 442677f2..d2fdda75 100644 --- a/lib/i18n/interpolate/ruby.rb +++ b/lib/i18n/interpolate/ruby.rb @@ -22,7 +22,7 @@ def interpolate_hash(string, values) if match == '%%' '%' else - key = ($1 || $2).to_sym + key = ($1 || $2 || match.tr("%{}", "")).to_sym value = if values.key?(key) values[key] else diff --git a/test/i18n/interpolate_test.rb b/test/i18n/interpolate_test.rb index 7041b322..59f26791 100644 --- a/test/i18n/interpolate_test.rb +++ b/test/i18n/interpolate_test.rb @@ -58,6 +58,17 @@ class I18nInterpolateTest < Test::Unit::TestCase def test_sprintf_mix_unformatted_and_formatted_named_placeholders assert_equal "foo 1.000000", I18n.interpolate("%{name} %f", :name => "foo", :num => 1.0) end + + class RailsSafeBuffer < String + + def gsub(*args, &block) + to_str.gsub(*args, &block) + end + + end + test "with String subclass that redefined gsub method" do + assert_equal "Hello mars world", I18n.interpolate(RailsSafeBuffer.new("Hello %{planet} world"), :planet => 'mars') + end end class I18nMissingInterpolationCustomHandlerTest < Test::Unit::TestCase From d100659906ef2a0a80abedd58c8e6c07ea6a2cd8 Mon Sep 17 00:00:00 2001 From: "Romulo A. Ceccon" Date: Sat, 7 Dec 2013 10:33:41 -0200 Subject: [PATCH 005/145] Test for issue with Fallbacks and enforce_available_locales Created a test-case for an issue where the Fallbacks module will generate an I18n::InvalidLocale error. Fallbacks relies on I18n.translation to find out whether there's a translation for a fallback locale (e.g. :'de' for :'de-DE'). But I18n.translation does not distinguish from a "user" call and one coming from the Fallbacks module, and may raise I18n::InvalidLocale if enforce_available_locales is set. --- test/backend/fallbacks_test.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/backend/fallbacks_test.rb b/test/backend/fallbacks_test.rb index 2b17da94..6ea09207 100644 --- a/test/backend/fallbacks_test.rb +++ b/test/backend/fallbacks_test.rb @@ -10,6 +10,7 @@ def setup store_translations(:en, :foo => 'Foo in :en', :bar => 'Bar in :en', :buz => 'Buz in :en') store_translations(:de, :bar => 'Bar in :de', :baz => 'Baz in :de') store_translations(:'de-DE', :baz => 'Baz in :de-DE') + store_translations(:'pt-BR', :baz => 'Baz in :pt-BR') end test "still returns an existing translation as usual" do @@ -74,6 +75,15 @@ def setup test "should ensure that default is not splitted on new line char" do assert_equal "Default \n Bar", I18n.t(:missing_bar, :default => "Default \n Bar") end + + test "should not raise error when enforce_available_locales is true, :'pt' is missing and default is a Symbol" do + I18n.enforce_available_locales = true + begin + assert_equal 'Foo', I18n.t(:'model.attrs.foo', :locale => :'pt-BR', :default => [:'attrs.foo', "Foo"]) + ensure + I18n.enforce_available_locales = false + end + end end class I18nBackendFallbacksLocalizeTest < Test::Unit::TestCase From 12aa0f0d0fc1822d6825d81bb9cdfdc4eb325dfd Mon Sep 17 00:00:00 2001 From: "Romulo A. Ceccon" Date: Sat, 7 Dec 2013 16:09:06 +0000 Subject: [PATCH 006/145] Fixes issue with Fallbacks and enforce_available_locales Fallbacks should check whether each fallback location being tried was set by store_translations before deferring to I18n.translate. Otherwise a I18n::InvalidLocale may be raised when enforce_available_locales is set. --- lib/i18n/backend/fallbacks.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/i18n/backend/fallbacks.rb b/lib/i18n/backend/fallbacks.rb index 7252bb00..e55e0226 100644 --- a/lib/i18n/backend/fallbacks.rb +++ b/lib/i18n/backend/fallbacks.rb @@ -40,6 +40,7 @@ def translate(locale, key, options = {}) options[:fallback] = true I18n.fallbacks[locale].each do |fallback| + next unless translations.keys.include?(fallback) catch(:exception) do result = super(fallback, key, options) return result unless result.nil? From 3d039354e36005a1829e015dc7bf37f865529a35 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Thu, 12 Dec 2013 09:16:23 -0200 Subject: [PATCH 007/145] Fix instance variable not defined warnings due to added deprecations Also fix the rescue_format deprecation, it seems it was never being triggered because it was checking for the existence of a not yet defined variable. --- lib/i18n.rb | 4 ++-- lib/i18n/exceptions.rb | 2 +- test/i18n/exceptions_test.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/i18n.rb b/lib/i18n.rb index ca477ea1..8fd756c3 100755 --- a/lib/i18n.rb +++ b/lib/i18n.rb @@ -358,8 +358,8 @@ def default_exception_handler(exception, locale, key, options) end def handle_enforce_available_locales_deprecation - if config.enforce_available_locales.nil? && !@unenforced_available_locales_deprecation - $stderr.puts "[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message." + if config.enforce_available_locales.nil? && !defined?(@unenforced_available_locales_deprecation) + $stderr.puts "[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message." @unenforced_available_locales_deprecation = true end end diff --git a/lib/i18n/exceptions.rb b/lib/i18n/exceptions.rb index 48d50b85..3e0b1c58 100644 --- a/lib/i18n/exceptions.rb +++ b/lib/i18n/exceptions.rb @@ -13,7 +13,7 @@ def call(exception, locale, key, options) # TODO: this block is to be replaced by `exception.message` when # rescue_format is removed if options[:rescue_format] == :html - if @rescue_format_deprecation + if !defined?(@rescue_format_deprecation) $stderr.puts "[DEPRECATED] I18n's :recue_format option will be removed from a future release. All exception messages will be plain text. If you need the exception handler to return an html format please set or pass a custom exception handler." @rescue_format_deprecation = true end diff --git a/test/i18n/exceptions_test.rb b/test/i18n/exceptions_test.rb index 098eefe6..3db4395c 100644 --- a/test/i18n/exceptions_test.rb +++ b/test/i18n/exceptions_test.rb @@ -3,7 +3,7 @@ class I18nExceptionsTest < Test::Unit::TestCase def test_invalid_locale_stores_locale force_invalid_locale - rescue I18n::ArgumentError => e + rescue I18n::ArgumentError => exception assert_nil exception.locale end From e8c106010a641d57e5885855986be61070f5b95a Mon Sep 17 00:00:00 2001 From: buddhamagnet Date: Sun, 19 Jan 2014 19:52:59 +0000 Subject: [PATCH 008/145] make code in suppress_warnings.rb more concise --- lib/i18n/core_ext/kernel/suppress_warnings.rb | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 lib/i18n/core_ext/kernel/suppress_warnings.rb diff --git a/lib/i18n/core_ext/kernel/suppress_warnings.rb b/lib/i18n/core_ext/kernel/suppress_warnings.rb new file mode 100644 index 00000000..c2504116 --- /dev/null +++ b/lib/i18n/core_ext/kernel/suppress_warnings.rb @@ -0,0 +1,8 @@ +module Kernel + def suppress_warnings + original_verbosity, $VERBOSE = $VERBOSE, nil + result = yield + $VERBOSE = original_verbosity + result + end +end From a6ea92773b2ead81327ed1fcd90effc00713aab7 Mon Sep 17 00:00:00 2001 From: Semyon Perepelitsa Date: Sat, 15 Feb 2014 22:39:00 +0800 Subject: [PATCH 009/145] I18n.locale= and default_locale= now fail given junk values. Only strings and nil allowed. --- lib/i18n/config.rb | 4 ++-- test/i18n_test.rb | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/i18n/config.rb b/lib/i18n/config.rb index 76293a1a..8ac84eb5 100644 --- a/lib/i18n/config.rb +++ b/lib/i18n/config.rb @@ -9,7 +9,7 @@ def locale # Sets the current locale pseudo-globally, i.e. in the Thread.current hash. def locale=(locale) I18n.enforce_available_locales!(locale) - @locale = locale.to_sym rescue nil + @locale = locale && locale.to_sym end # Returns the current backend. Defaults to +Backend::Simple+. @@ -30,7 +30,7 @@ def default_locale # Sets the current default locale. Used to set a custom default locale. def default_locale=(locale) I18n.enforce_available_locales!(locale) - @@default_locale = locale.to_sym rescue nil + @@default_locale = locale && locale.to_sym end # Returns an array of locales for which translations are available. diff --git a/test/i18n_test.rb b/test/i18n_test.rb index 040d4cb9..74535051 100644 --- a/test/i18n_test.rb +++ b/test/i18n_test.rb @@ -37,6 +37,10 @@ def setup end end + test "default_locale= doesn't ignore junk" do + assert_raise(NoMethodError) { I18n.default_locale = Class } + end + test "raises an I18n::InvalidLocale exception when setting an unavailable default locale" do begin I18n.config.enforce_available_locales = true @@ -57,6 +61,10 @@ def setup I18n.locale = :en end + test "locale= doesn't ignore junk" do + assert_raise(NoMethodError) { I18n.locale = Class } + end + test "raises an I18n::InvalidLocale exception when setting an unavailable locale" do begin I18n.config.enforce_available_locales = true From 31ce276d4045a1990b367b9dd36ced6f4f1449a2 Mon Sep 17 00:00:00 2001 From: Simeon Simeonov Date: Fri, 21 Feb 2014 23:43:01 -0500 Subject: [PATCH 010/145] Ensure original verbosity in case of exceptions --- lib/i18n/core_ext/kernel/surpress_warnings.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/i18n/core_ext/kernel/surpress_warnings.rb b/lib/i18n/core_ext/kernel/surpress_warnings.rb index cc03b1c1..b037b860 100644 --- a/lib/i18n/core_ext/kernel/surpress_warnings.rb +++ b/lib/i18n/core_ext/kernel/surpress_warnings.rb @@ -2,8 +2,8 @@ module Kernel def suppress_warnings original_verbosity = $VERBOSE $VERBOSE = nil - result = yield + yield + ensure $VERBOSE = original_verbosity - result end end From a65fffd6f0472bc413ba41809dafc6292e29d2ae Mon Sep 17 00:00:00 2001 From: Arthur Neves Date: Mon, 7 Apr 2014 11:28:22 -0400 Subject: [PATCH 011/145] Improve performance on enforce_available_locales! Cache the available_locales in a local Set, so we can lookup, and check for inclusions faster. [fixes #230] --- lib/i18n.rb | 2 +- lib/i18n/config.rb | 7 +++++++ test/i18n_test.rb | 19 ++++++++++++++++++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/lib/i18n.rb b/lib/i18n.rb index 8fd756c3..7e492a59 100755 --- a/lib/i18n.rb +++ b/lib/i18n.rb @@ -275,7 +275,7 @@ def normalize_keys(locale, key, scope, separator = nil) # Returns false otherwise. # Compare with Strings as `locale` may be coming from user input def locale_available?(locale) - I18n.available_locales.map(&:to_s).include?(locale.to_s) + I18n.config.available_locales_set.include?(locale) end # Raises an InvalidLocale exception when the passed locale is not diff --git a/lib/i18n/config.rb b/lib/i18n/config.rb index 76293a1a..3fc8a615 100644 --- a/lib/i18n/config.rb +++ b/lib/i18n/config.rb @@ -41,10 +41,17 @@ def available_locales @@available_locales || backend.available_locales end + def available_locales_set + @@available_locales_set ||= available_locales.inject(Set.new) do |set, locale| + set << locale.to_s << locale.to_sym + end + end + # Sets the available locales. def available_locales=(locales) @@available_locales = Array(locales).map { |locale| locale.to_sym } @@available_locales = nil if @@available_locales.empty? + @@available_locales_set = nil end # Returns the current default scope separator. Defaults to '.' diff --git a/test/i18n_test.rb b/test/i18n_test.rb index 040d4cb9..c99450e1 100644 --- a/test/i18n_test.rb +++ b/test/i18n_test.rb @@ -56,7 +56,7 @@ def setup assert_equal :de, Thread.current[:i18n_config].locale I18n.locale = :en end - + test "raises an I18n::InvalidLocale exception when setting an unavailable locale" do begin I18n.config.enforce_available_locales = true @@ -215,6 +215,23 @@ def setup end end + test "available_locales can be replaced at runtime" do + begin + I18n.config.enforce_available_locales = true + assert_raise(I18n::InvalidLocale) { I18n.t(:foo, :locale => 'klingon') } + old_locales, I18n.config.available_locales = I18n.config.available_locales, [:klingon] + I18n.t(:foo, :locale => 'klingon') + ensure + I18n.config.enforce_available_locales = false + I18n.config.available_locales = old_locales + end + end + + test "available_locales_set should return a set" do + assert_equal Set, I18n.config.available_locales_set.class + assert_equal (I18n.config.available_locales.size * 2), I18n.config.available_locales_set.size + end + test "exists? given an existing key will return true" do assert_equal true, I18n.exists?(:currency) end From 1b5d29c9a6bcf6401cdacf7d25f42c9b69031752 Mon Sep 17 00:00:00 2001 From: Chipairon Date: Tue, 22 Apr 2014 12:16:12 +0200 Subject: [PATCH 012/145] The proc is executed by Kernel#eval and the methods used from within need to be fully qualified to be 'findable' when being evaluated. --- lib/i18n/tests/localization/procs.rb | 10 +++++----- lib/i18n/tests/procs.rb | 18 +++++++++--------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/i18n/tests/localization/procs.rb b/lib/i18n/tests/localization/procs.rb index 7b7813e2..bdfa9480 100644 --- a/lib/i18n/tests/localization/procs.rb +++ b/lib/i18n/tests/localization/procs.rb @@ -52,19 +52,19 @@ module Procs test "localize Time: given a format that resolves to a Proc it calls the Proc with the object" do setup_time_proc_translations time = ::Time.utc(2008, 3, 1, 6, 0) - assert_equal inspect_args([time, {}]), I18n.l(time, :format => :proc, :locale => :ru) + assert_equal I18n::Tests::Localization::Procs.inspect_args([time, {}]), I18n.l(time, :format => :proc, :locale => :ru) end test "localize Time: given a format that resolves to a Proc it calls the Proc with the object and extra options" do setup_time_proc_translations time = ::Time.utc(2008, 3, 1, 6, 0) options = { :foo => 'foo' } - assert_equal inspect_args([time, options]), I18n.l(time, options.merge(:format => :proc, :locale => :ru)) + assert_equal I18n::Tests::Localization::Procs.inspect_args([time, options]), I18n.l(time, options.merge(:format => :proc, :locale => :ru)) end protected - def inspect_args(args) + def self.inspect_args(args) args = args.map do |arg| case arg when ::Time, ::DateTime @@ -85,12 +85,12 @@ def setup_time_proc_translations I18n.backend.store_translations :ru, { :time => { :formats => { - :proc => lambda { |*args| inspect_args(args) } + :proc => lambda { |*args| I18n::Tests::Localization::Procs.inspect_args(args) } } }, :date => { :formats => { - :proc => lambda { |*args| inspect_args(args) } + :proc => lambda { |*args| I18n::Tests::Localization::Procs.inspect_args(args) } }, :'day_names' => lambda { |key, options| (options[:format] =~ /^%A/) ? diff --git a/lib/i18n/tests/procs.rb b/lib/i18n/tests/procs.rb index 55ff9529..02db95cb 100644 --- a/lib/i18n/tests/procs.rb +++ b/lib/i18n/tests/procs.rb @@ -4,28 +4,29 @@ module I18n module Tests module Procs test "lookup: given a translation is a proc it calls the proc with the key and interpolation values" do - I18n.backend.store_translations(:en, :a_lambda => lambda { |*args| filter_args(*args) }) + I18n.backend.store_translations(:en, :a_lambda => lambda { |*args| I18n::Tests::Procs.filter_args(*args) }) assert_equal '[:a_lambda, {:foo=>"foo"}]', I18n.t(:a_lambda, :foo => 'foo') end test "defaults: given a default is a Proc it calls it with the key and interpolation values" do - proc = lambda { |*args| filter_args(*args) } + proc = lambda { |*args| I18n::Tests::Procs.filter_args(*args) } assert_equal '[nil, {:foo=>"foo"}]', I18n.t(nil, :default => proc, :foo => 'foo') end test "defaults: given a default is a key that resolves to a Proc it calls it with the key and interpolation values" do - I18n.backend.store_translations(:en, :a_lambda => lambda { |*args| filter_args(*args) }) + the_lambda = lambda { |*args| I18n::Tests::Procs.filter_args(*args) } + I18n.backend.store_translations(:en, :a_lambda => the_lambda) assert_equal '[:a_lambda, {:foo=>"foo"}]', I18n.t(nil, :default => :a_lambda, :foo => 'foo') assert_equal '[:a_lambda, {:foo=>"foo"}]', I18n.t(nil, :default => [nil, :a_lambda], :foo => 'foo') end test "interpolation: given an interpolation value is a lambda it calls it with key and values before interpolating it" do - proc = lambda { |*args| filter_args(*args) } + proc = lambda { |*args| I18n::Tests::Procs.filter_args(*args) } assert_match %r(\[\{:foo=>#\}\]), I18n.t(nil, :default => '%{foo}', :foo => proc) end test "interpolation: given a key resolves to a Proc that returns a string then interpolation still works" do - proc = lambda { |*args| "%{foo}: " + filter_args(*args) } + proc = lambda { |*args| "%{foo}: " + I18n::Tests::Procs.filter_args(*args) } assert_equal 'foo: [nil, {:foo=>"foo"}]', I18n.t(nil, :default => proc, :foo => 'foo') end @@ -37,17 +38,16 @@ module Procs end test "lookup: given the option :resolve => false was passed it does not resolve proc translations" do - I18n.backend.store_translations(:en, :a_lambda => lambda { |*args| filter_args(*args) }) + I18n.backend.store_translations(:en, :a_lambda => lambda { |*args| I18n::Tests::Procs.filter_args(*args) }) assert_equal Proc, I18n.t(:a_lambda, :resolve => false).class end test "lookup: given the option :resolve => false was passed it does not resolve proc default" do - assert_equal Proc, I18n.t(nil, :default => lambda { |*args| filter_args(*args) }, :resolve => false).class + assert_equal Proc, I18n.t(nil, :default => lambda { |*args| I18n::Tests::Procs.filter_args(*args) }, :resolve => false).class end - protected - def filter_args(*args) + def self.filter_args(*args) args.map {|arg| arg.delete(:fallback) if arg.is_a?(Hash) ; arg }.inspect end end From 3a582ed471e2f61ecd358a7289f30da54ed007b7 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Mon, 5 May 2014 08:36:06 -0300 Subject: [PATCH 013/145] Fix typo in filename: surpress => suppress --- lib/i18n/backend/base.rb | 2 +- .../kernel/{surpress_warnings.rb => suppress_warnings.rb} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename lib/i18n/core_ext/kernel/{surpress_warnings.rb => suppress_warnings.rb} (100%) diff --git a/lib/i18n/backend/base.rb b/lib/i18n/backend/base.rb index dddb145a..4a823bc4 100644 --- a/lib/i18n/backend/base.rb +++ b/lib/i18n/backend/base.rb @@ -1,6 +1,6 @@ require 'yaml' require 'i18n/core_ext/hash' -require 'i18n/core_ext/kernel/surpress_warnings' +require 'i18n/core_ext/kernel/suppress_warnings' module I18n module Backend diff --git a/lib/i18n/core_ext/kernel/surpress_warnings.rb b/lib/i18n/core_ext/kernel/suppress_warnings.rb similarity index 100% rename from lib/i18n/core_ext/kernel/surpress_warnings.rb rename to lib/i18n/core_ext/kernel/suppress_warnings.rb From 3a308264ec878229a05e3911396aeda8e95e7072 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Wed, 30 Apr 2014 19:53:22 -0300 Subject: [PATCH 014/145] Get rid of unused method on test helper --- test/test_helper.rb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/test/test_helper.rb b/test/test_helper.rb index 982dd2d6..ee3f143a 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -48,9 +48,3 @@ def setup_rufus_tokyo puts "can't use KeyValue backend because: #{e.message}" end end - -Object.class_eval do - def meta_class - class << self; self; end - end -end unless Object.method_defined?(:meta_class) From 4f996db836aea85ae85bf4f07811e497340994eb Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Wed, 30 Apr 2014 19:54:29 -0300 Subject: [PATCH 015/145] Also return enforce_available_locales to the default nil Since all other defaults are being reverted to the default, do that with enforce_available_locales too. --- test/test_helper.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test_helper.rb b/test/test_helper.rb index ee3f143a..f9f15204 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -24,6 +24,7 @@ def teardown I18n.load_path = [] I18n.available_locales = nil I18n.backend = nil + I18n.enforce_available_locales = nil end def translations From 0fc31d9e684c8a9bf5fbcbf154ed770e49cc0c95 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Wed, 30 Apr 2014 20:01:30 -0300 Subject: [PATCH 016/145] Simplify store translations helper which does not make use of default args --- test/test_helper.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/test_helper.rb b/test/test_helper.rb index f9f15204..4fc8a3f3 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -31,9 +31,7 @@ def translations I18n.backend.instance_variable_get(:@translations) end - def store_translations(*args) - data = args.pop - locale = args.pop || :en + def store_translations(locale, data) I18n.backend.store_translations(locale, data) end From 9a157af5394dbffd81cbfd788fd055ed1aa2ec77 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Wed, 30 Apr 2014 20:05:58 -0300 Subject: [PATCH 017/145] Use store translations helper in some tests --- test/backend/simple_test.rb | 10 +++++----- test/i18n/exceptions_test.rb | 8 ++++---- test/i18n_test.rb | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/test/backend/simple_test.rb b/test/backend/simple_test.rb index 3ebc8ee4..4f37f48e 100644 --- a/test/backend/simple_test.rb +++ b/test/backend/simple_test.rb @@ -49,23 +49,23 @@ def setup # storing translations test "simple store_translations: stores translations, ... no, really :-)" do - I18n.backend.store_translations :'en', :foo => 'bar' + store_translations :'en', :foo => 'bar' assert_equal Hash[:'en', {:foo => 'bar'}], translations end test "simple store_translations: deep_merges with existing translations" do - I18n.backend.store_translations :'en', :foo => {:bar => 'bar'} - I18n.backend.store_translations :'en', :foo => {:baz => 'baz'} + store_translations :'en', :foo => {:bar => 'bar'} + store_translations :'en', :foo => {:baz => 'baz'} assert_equal Hash[:'en', {:foo => {:bar => 'bar', :baz => 'baz'}}], translations end test "simple store_translations: converts the given locale to a Symbol" do - I18n.backend.store_translations 'en', :foo => 'bar' + store_translations 'en', :foo => 'bar' assert_equal Hash[:'en', {:foo => 'bar'}], translations end test "simple store_translations: converts keys to Symbols" do - I18n.backend.store_translations 'en', 'foo' => {'bar' => 'bar', 'baz' => 'baz'} + store_translations 'en', 'foo' => {'bar' => 'bar', 'baz' => 'baz'} assert_equal Hash[:'en', {:foo => {:bar => 'bar', :baz => 'baz'}}], translations end diff --git a/test/i18n/exceptions_test.rb b/test/i18n/exceptions_test.rb index 3db4395c..2e5e1898 100644 --- a/test/i18n/exceptions_test.rb +++ b/test/i18n/exceptions_test.rb @@ -91,28 +91,28 @@ def force_invalid_locale end def force_missing_translation_data(options = {}) - I18n.backend.store_translations('de', :bar => nil) + store_translations('de', :bar => nil) I18n.translate(:foo, options.merge(:scope => :bar, :locale => :de)) rescue I18n::ArgumentError => e block_given? ? yield(e) : raise(e) end def force_invalid_pluralization_data - I18n.backend.store_translations('de', :foo => [:bar]) + store_translations('de', :foo => [:bar]) I18n.translate(:foo, :count => 1, :locale => :de) rescue I18n::ArgumentError => e block_given? ? yield(e) : raise(e) end def force_missing_interpolation_argument - I18n.backend.store_translations('de', :foo => "%{bar}") + store_translations('de', :foo => "%{bar}") I18n.translate(:foo, :baz => 'baz', :locale => :de) rescue I18n::ArgumentError => e block_given? ? yield(e) : raise(e) end def force_reserved_interpolation_key - I18n.backend.store_translations('de', :foo => "%{scope}") + store_translations('de', :foo => "%{scope}") I18n.translate(:foo, :baz => 'baz', :locale => :de) rescue I18n::ArgumentError => e block_given? ? yield(e) : raise(e) diff --git a/test/i18n_test.rb b/test/i18n_test.rb index 040d4cb9..2d6e641b 100644 --- a/test/i18n_test.rb +++ b/test/i18n_test.rb @@ -3,8 +3,8 @@ class I18nTest < Test::Unit::TestCase def setup - I18n.backend.store_translations(:'en', :currency => { :format => { :separator => '.', :delimiter => ',', } }) - I18n.backend.store_translations(:'nl', :currency => { :format => { :separator => ',', :delimiter => '.', } }) + store_translations(:en, :currency => { :format => { :separator => '.', :delimiter => ',', } }) + store_translations(:nl, :currency => { :format => { :separator => ',', :delimiter => '.', } }) end test "exposes its VERSION constant" do @@ -56,7 +56,7 @@ def setup assert_equal :de, Thread.current[:i18n_config].locale I18n.locale = :en end - + test "raises an I18n::InvalidLocale exception when setting an unavailable locale" do begin I18n.config.enforce_available_locales = true From 45e931496a83662b44be5e52b776bcd2a83a987d Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Wed, 30 Apr 2014 20:08:56 -0300 Subject: [PATCH 018/145] Stop messing up with the global namespace Create helper methods in namespaces we own. --- test/backend/interpolation_compiler_test.rb | 5 ++--- test/test_helper.rb | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/test/backend/interpolation_compiler_test.rb b/test/backend/interpolation_compiler_test.rb index f4d287a9..50170b2e 100644 --- a/test/backend/interpolation_compiler_test.rb +++ b/test/backend/interpolation_compiler_test.rb @@ -99,14 +99,14 @@ class I18nBackendInterpolationCompilerTest < Test::Unit::TestCase class Backend < I18n::Backend::Simple include I18n::Backend::InterpolationCompiler end - + include I18n::Tests::Interpolation def setup I18n.backend = Backend.new super end - + # pre-compile default strings to make sure we are testing I18n::Backend::InterpolationCompiler def interpolate(*args) options = args.last.kind_of?(Hash) ? args.last : {} @@ -115,5 +115,4 @@ def interpolate(*args) end super end - end diff --git a/test/test_helper.rb b/test/test_helper.rb index 4fc8a3f3..becc0a41 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -40,8 +40,8 @@ def locales_dir end end -module Kernel - def setup_rufus_tokyo +module I18n::Tests + def self.setup_rufus_tokyo require 'rufus/tokyo' rescue LoadError => e puts "can't use KeyValue backend because: #{e.message}" From 08d71323e33f3dfdde1dd500aaf82c65d870cf7b Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Wed, 30 Apr 2014 20:26:48 -0300 Subject: [PATCH 019/145] Update dependencies with: rake/mocha/test_declarative Add rake to default Gemfile since it's a necessary dependency to run tests. --- Gemfile.lock | 10 ++++++---- ci/Gemfile.no-rails | 2 +- ci/Gemfile.no-rails.lock | 12 +++++++----- i18n.gemspec | 5 ----- test/test_helper.rb | 3 ++- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 6dde73ae..6e05287b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,10 +1,11 @@ GEM remote: https://rubygems.org/ specs: - mocha (0.9.9) - rake - rake (0.8.7) - test_declarative (0.0.4) + metaclass (0.0.4) + mocha (1.0.0) + metaclass (~> 0.0.1) + rake (10.3.1) + test_declarative (0.0.5) PLATFORMS java @@ -12,4 +13,5 @@ PLATFORMS DEPENDENCIES mocha + rake test_declarative diff --git a/ci/Gemfile.no-rails b/ci/Gemfile.no-rails index 449613e8..4efc15e6 100644 --- a/ci/Gemfile.no-rails +++ b/ci/Gemfile.no-rails @@ -2,4 +2,4 @@ source 'https://rubygems.org' gem 'mocha' gem 'test_declarative' - +gem 'rake' diff --git a/ci/Gemfile.no-rails.lock b/ci/Gemfile.no-rails.lock index 569b32a7..ecd59534 100644 --- a/ci/Gemfile.no-rails.lock +++ b/ci/Gemfile.no-rails.lock @@ -1,14 +1,16 @@ GEM - remote: http://rubygems.org/ + remote: https://rubygems.org/ specs: - mocha (0.9.9) - rake - rake (0.8.7) - test_declarative (0.0.4) + metaclass (0.0.4) + mocha (1.0.0) + metaclass (~> 0.0.1) + rake (10.3.1) + test_declarative (0.0.5) PLATFORMS ruby DEPENDENCIES mocha + rake test_declarative diff --git a/i18n.gemspec b/i18n.gemspec index 4c22bb77..9a4a4de5 100644 --- a/i18n.gemspec +++ b/i18n.gemspec @@ -18,9 +18,4 @@ Gem::Specification.new do |s| s.require_path = 'lib' s.rubyforge_project = '[none]' s.required_rubygems_version = '>= 1.3.5' - - s.add_development_dependency 'activesupport', '>= 3.0.0' - s.add_development_dependency 'sqlite3' - s.add_development_dependency 'mocha' - s.add_development_dependency 'test_declarative' end diff --git a/test/test_helper.rb b/test/test_helper.rb index becc0a41..2b7805f5 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -14,7 +14,8 @@ def gem(gem_name, *version_requirements) require 'bundler/setup' require 'i18n' -require 'mocha' +require 'mocha/test_unit' +require 'mocha/setup' require 'test_declarative' class Test::Unit::TestCase From be668456494ed3d0ad21dde27d2dfa194cf5c94e Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Wed, 30 Apr 2014 20:27:33 -0300 Subject: [PATCH 020/145] Add Ruby 2.1.1 to travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 5b2a84e8..d939a320 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ rvm: - 1.9.2 - 1.9.3 - 2.0.0 + - 2.1.1 - ree - rbx - jruby From d7b71cf347458de5045b8e6f6382c17eced074dc Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Wed, 30 Apr 2014 20:47:34 -0300 Subject: [PATCH 021/145] Allow failures of some rubies and gemfiles for faster feedback --- .travis.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.travis.yml b/.travis.yml index d939a320..9ed55108 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,3 +12,12 @@ gemfile: - ci/Gemfile.no-rails - ci/Gemfile.rails-2.3.x - ci/Gemfile.rails-3.x + +matrix: + allow_failures: + - rvm: ree + - rvm: rbx + - rvm: jruby + - gemfile: ci/Gemfile.rails-2.3.x + - gemfile: ci/Gemfile.rails-3.x + fast_finish: true From a345d4e0cd62020c1893f720ba743efcee2af50b Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Mon, 5 May 2014 10:07:08 -0300 Subject: [PATCH 022/145] Add specific script/install to travis as an attempt to fix 1.8.7 build failure https://github.com/travis-ci/travis-ci/issues/2253 --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 9ed55108..188a0800 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,6 @@ +install: "ruby -S bundle install --deployment" +script: "bundle exec rake" + rvm: - 1.8.7 - 1.9.2 From be8c11ffe5e62d78167551bf748750407e86073a Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Mon, 5 May 2014 12:45:05 -0300 Subject: [PATCH 023/145] Update dependencies of rails Gemfiles --- ci/Gemfile.rails-2.3.x | 4 ++-- ci/Gemfile.rails-2.3.x.lock | 21 +++++++++++---------- ci/Gemfile.rails-3.x | 4 ++-- ci/Gemfile.rails-3.x.lock | 21 +++++++++++---------- 4 files changed, 26 insertions(+), 24 deletions(-) diff --git a/ci/Gemfile.rails-2.3.x b/ci/Gemfile.rails-2.3.x index 3227b3ae..fcfe4752 100644 --- a/ci/Gemfile.rails-2.3.x +++ b/ci/Gemfile.rails-2.3.x @@ -1,9 +1,9 @@ source 'https://rubygems.org' gem 'activesupport', '~> 2.3' -gem 'sqlite3-ruby' +gem 'sqlite3' gem 'mocha' gem 'test_declarative' gem 'rufus-tokyo' gem 'ffi' - +gem 'rake' diff --git a/ci/Gemfile.rails-2.3.x.lock b/ci/Gemfile.rails-2.3.x.lock index 60106158..f3a5b70f 100644 --- a/ci/Gemfile.rails-2.3.x.lock +++ b/ci/Gemfile.rails-2.3.x.lock @@ -1,15 +1,15 @@ GEM - remote: http://rubygems.org/ + remote: https://rubygems.org/ specs: - activesupport (2.3.10) - ffi (0.6.3) - rake (>= 0.8.7) - mocha (0.9.9) - rake - rake (0.8.7) + activesupport (2.3.18) + ffi (1.9.3) + metaclass (0.0.4) + mocha (1.0.0) + metaclass (~> 0.0.1) + rake (10.3.1) rufus-tokyo (1.0.7) - sqlite3-ruby (1.3.2) - test_declarative (0.0.4) + sqlite3 (1.3.9) + test_declarative (0.0.5) PLATFORMS ruby @@ -18,6 +18,7 @@ DEPENDENCIES activesupport (~> 2.3) ffi mocha + rake rufus-tokyo - sqlite3-ruby + sqlite3 test_declarative diff --git a/ci/Gemfile.rails-3.x b/ci/Gemfile.rails-3.x index d0947e55..2ee8e91c 100644 --- a/ci/Gemfile.rails-3.x +++ b/ci/Gemfile.rails-3.x @@ -1,9 +1,9 @@ source 'https://rubygems.org' gem 'activesupport', '~> 3.0.0' -gem 'sqlite3-ruby' +gem 'sqlite3' gem 'mocha' gem 'test_declarative' gem 'rufus-tokyo' gem 'ffi' - +gem 'rake' diff --git a/ci/Gemfile.rails-3.x.lock b/ci/Gemfile.rails-3.x.lock index de7aad6a..d58d9e9a 100644 --- a/ci/Gemfile.rails-3.x.lock +++ b/ci/Gemfile.rails-3.x.lock @@ -1,15 +1,15 @@ GEM - remote: http://rubygems.org/ + remote: https://rubygems.org/ specs: - activesupport (3.0.3) - ffi (0.6.3) - rake (>= 0.8.7) - mocha (0.9.9) - rake - rake (0.8.7) + activesupport (3.0.20) + ffi (1.9.3) + metaclass (0.0.4) + mocha (1.0.0) + metaclass (~> 0.0.1) + rake (10.3.1) rufus-tokyo (1.0.7) - sqlite3-ruby (1.3.2) - test_declarative (0.0.4) + sqlite3 (1.3.9) + test_declarative (0.0.5) PLATFORMS ruby @@ -18,6 +18,7 @@ DEPENDENCIES activesupport (~> 3.0.0) ffi mocha + rake rufus-tokyo - sqlite3-ruby + sqlite3 test_declarative From 02205ff0996ed014f35524552389bc2ae2279a34 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Mon, 5 May 2014 13:10:53 -0300 Subject: [PATCH 024/145] Try to install tokyo cabinet ruby bindings on travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 188a0800..c76de590 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ +before_install: "sudo apt-get install ruby-tokyocabinet -y" install: "ruby -S bundle install --deployment" script: "bundle exec rake" From 5f60c6dc90c657eee43760b28181d253c2ce8d6c Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Mon, 5 May 2014 13:26:24 -0300 Subject: [PATCH 025/145] Try to downgrade AS versions for now since latest ones seem to break lots of tests Due to the addition of OkJson as the default JSON backend, lots of tests are breaking, so this is a test to see if we can get to green before any other change. --- ci/Gemfile.rails-2.3.x.lock | 2 +- ci/Gemfile.rails-3.x.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/Gemfile.rails-2.3.x.lock b/ci/Gemfile.rails-2.3.x.lock index f3a5b70f..a7b78470 100644 --- a/ci/Gemfile.rails-2.3.x.lock +++ b/ci/Gemfile.rails-2.3.x.lock @@ -1,7 +1,7 @@ GEM remote: https://rubygems.org/ specs: - activesupport (2.3.18) + activesupport (2.3.15) ffi (1.9.3) metaclass (0.0.4) mocha (1.0.0) diff --git a/ci/Gemfile.rails-3.x.lock b/ci/Gemfile.rails-3.x.lock index d58d9e9a..b4f7b4d3 100644 --- a/ci/Gemfile.rails-3.x.lock +++ b/ci/Gemfile.rails-3.x.lock @@ -1,7 +1,7 @@ GEM remote: https://rubygems.org/ specs: - activesupport (3.0.20) + activesupport (3.0.19) ffi (1.9.3) metaclass (0.0.4) mocha (1.0.0) From a0b4520c06e5ce7af633148a564ebd9b3ef11c48 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Mon, 5 May 2014 14:09:56 -0300 Subject: [PATCH 026/145] Do not run tests with Rails 2.3.x and Ruby 2.x / RBX / JRuby And reenable Rails 2.3 and 3.0 tests, they should be green now. --- .travis.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c76de590..41819d17 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,6 +22,13 @@ matrix: - rvm: ree - rvm: rbx - rvm: jruby + exclude: - gemfile: ci/Gemfile.rails-2.3.x - - gemfile: ci/Gemfile.rails-3.x + rvm: 2.0.0 + - gemfile: ci/Gemfile.rails-2.3.x + rvm: 2.1.1 + - gemfile: ci/Gemfile.rails-2.3.x + rvm: rbx + - gemfile: ci/Gemfile.rails-2.3.x + rvm: jruby fast_finish: true From 6689c7a39750b59e722acdad222ca225a0fc843e Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Mon, 5 May 2014 14:51:22 -0300 Subject: [PATCH 027/145] Get rid of useless sqlite3 dependency on Rails gemfiles --- ci/Gemfile.rails-2.3.x | 1 - ci/Gemfile.rails-2.3.x.lock | 2 -- ci/Gemfile.rails-3.x | 1 - ci/Gemfile.rails-3.x.lock | 2 -- 4 files changed, 6 deletions(-) diff --git a/ci/Gemfile.rails-2.3.x b/ci/Gemfile.rails-2.3.x index fcfe4752..7df073d2 100644 --- a/ci/Gemfile.rails-2.3.x +++ b/ci/Gemfile.rails-2.3.x @@ -1,7 +1,6 @@ source 'https://rubygems.org' gem 'activesupport', '~> 2.3' -gem 'sqlite3' gem 'mocha' gem 'test_declarative' gem 'rufus-tokyo' diff --git a/ci/Gemfile.rails-2.3.x.lock b/ci/Gemfile.rails-2.3.x.lock index a7b78470..6fcb50cc 100644 --- a/ci/Gemfile.rails-2.3.x.lock +++ b/ci/Gemfile.rails-2.3.x.lock @@ -8,7 +8,6 @@ GEM metaclass (~> 0.0.1) rake (10.3.1) rufus-tokyo (1.0.7) - sqlite3 (1.3.9) test_declarative (0.0.5) PLATFORMS @@ -20,5 +19,4 @@ DEPENDENCIES mocha rake rufus-tokyo - sqlite3 test_declarative diff --git a/ci/Gemfile.rails-3.x b/ci/Gemfile.rails-3.x index 2ee8e91c..57c9d10f 100644 --- a/ci/Gemfile.rails-3.x +++ b/ci/Gemfile.rails-3.x @@ -1,7 +1,6 @@ source 'https://rubygems.org' gem 'activesupport', '~> 3.0.0' -gem 'sqlite3' gem 'mocha' gem 'test_declarative' gem 'rufus-tokyo' diff --git a/ci/Gemfile.rails-3.x.lock b/ci/Gemfile.rails-3.x.lock index b4f7b4d3..ccb92e9b 100644 --- a/ci/Gemfile.rails-3.x.lock +++ b/ci/Gemfile.rails-3.x.lock @@ -8,7 +8,6 @@ GEM metaclass (~> 0.0.1) rake (10.3.1) rufus-tokyo (1.0.7) - sqlite3 (1.3.9) test_declarative (0.0.5) PLATFORMS @@ -20,5 +19,4 @@ DEPENDENCIES mocha rake rufus-tokyo - sqlite3 test_declarative From b4a08f39b79c54f90f9e09bd27be97b5de534c15 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Tue, 6 May 2014 07:36:16 -0300 Subject: [PATCH 028/145] Revert "Add specific script/install to travis as an attempt to fix 1.8.7 build failure" This reverts commit a345d4e0cd62020c1893f720ba743efcee2af50b. Conflicts: .travis.yml Reason: travis Ruby build has been updated with a fix for 1.8.7 + rake. https://github.com/travis-ci/travis-ci/issues/2253#issuecomment-42264423 --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 41819d17..7f12de54 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,4 @@ before_install: "sudo apt-get install ruby-tokyocabinet -y" -install: "ruby -S bundle install --deployment" -script: "bundle exec rake" rvm: - 1.8.7 From bf1f2b29e7d0899c9acd7c8f95154f30db4cec81 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Tue, 6 May 2014 18:40:10 -0300 Subject: [PATCH 029/145] No need to require mocha/test_unit with mocha/setup --- test/test_helper.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/test/test_helper.rb b/test/test_helper.rb index 2b7805f5..e23b5abb 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -14,7 +14,6 @@ def gem(gem_name, *version_requirements) require 'bundler/setup' require 'i18n' -require 'mocha/test_unit' require 'mocha/setup' require 'test_declarative' From 877e78eb3a780dd78c64737ad69587c6ea4fc9d8 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Tue, 6 May 2014 18:56:57 -0300 Subject: [PATCH 030/145] Bump Rails 2.3/3.0 versions to latest and use Yajl as JSON backend The Rails implementation that uses OkJson simply fails the key value tests we have, whereas Yajl seems to work fine. I'll leave Yajl for now to have the tests passing on latest 2.3/3.0 versions, and we can get rid of all this after removing support for older Rails versions. --- ci/Gemfile.rails-2.3.x | 1 + ci/Gemfile.rails-2.3.x.lock | 4 +++- ci/Gemfile.rails-3.x | 1 + ci/Gemfile.rails-3.x.lock | 4 +++- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ci/Gemfile.rails-2.3.x b/ci/Gemfile.rails-2.3.x index 7df073d2..15c6f531 100644 --- a/ci/Gemfile.rails-2.3.x +++ b/ci/Gemfile.rails-2.3.x @@ -6,3 +6,4 @@ gem 'test_declarative' gem 'rufus-tokyo' gem 'ffi' gem 'rake' +gem 'yajl-ruby' diff --git a/ci/Gemfile.rails-2.3.x.lock b/ci/Gemfile.rails-2.3.x.lock index 6fcb50cc..3a7d69da 100644 --- a/ci/Gemfile.rails-2.3.x.lock +++ b/ci/Gemfile.rails-2.3.x.lock @@ -1,7 +1,7 @@ GEM remote: https://rubygems.org/ specs: - activesupport (2.3.15) + activesupport (2.3.18) ffi (1.9.3) metaclass (0.0.4) mocha (1.0.0) @@ -9,6 +9,7 @@ GEM rake (10.3.1) rufus-tokyo (1.0.7) test_declarative (0.0.5) + yajl-ruby (1.2.0) PLATFORMS ruby @@ -20,3 +21,4 @@ DEPENDENCIES rake rufus-tokyo test_declarative + yajl-ruby diff --git a/ci/Gemfile.rails-3.x b/ci/Gemfile.rails-3.x index 57c9d10f..83006003 100644 --- a/ci/Gemfile.rails-3.x +++ b/ci/Gemfile.rails-3.x @@ -6,3 +6,4 @@ gem 'test_declarative' gem 'rufus-tokyo' gem 'ffi' gem 'rake' +gem 'yajl-ruby' diff --git a/ci/Gemfile.rails-3.x.lock b/ci/Gemfile.rails-3.x.lock index ccb92e9b..6d27cee7 100644 --- a/ci/Gemfile.rails-3.x.lock +++ b/ci/Gemfile.rails-3.x.lock @@ -1,7 +1,7 @@ GEM remote: https://rubygems.org/ specs: - activesupport (3.0.19) + activesupport (3.0.20) ffi (1.9.3) metaclass (0.0.4) mocha (1.0.0) @@ -9,6 +9,7 @@ GEM rake (10.3.1) rufus-tokyo (1.0.7) test_declarative (0.0.5) + yajl-ruby (1.2.0) PLATFORMS ruby @@ -20,3 +21,4 @@ DEPENDENCIES rake rufus-tokyo test_declarative + yajl-ruby From 41b5c258b4bf39c20859938dc9af6cfeb4202e90 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Tue, 6 May 2014 19:23:53 -0300 Subject: [PATCH 031/145] Add Rails 3.1, 3.2, 4.0 and 4.1 gemfiles --- .travis.yml | 18 ++++++++- Gemfile.lock | 6 +++ ci/Gemfile.no-rails | 2 + ci/Gemfile.no-rails.lock | 6 +++ ci/Gemfile.rails-2.3.x | 2 + ci/Gemfile.rails-2.3.x.lock | 6 +++ ci/{Gemfile.rails-3.x => Gemfile.rails-3.0.x} | 2 + ...ails-3.x.lock => Gemfile.rails-3.0.x.lock} | 6 +++ ci/Gemfile.rails-3.1.x | 10 +++++ ci/Gemfile.rails-3.1.x.lock | 30 +++++++++++++++ ci/Gemfile.rails-3.2.x | 10 +++++ ci/Gemfile.rails-3.2.x.lock | 31 ++++++++++++++++ ci/Gemfile.rails-4.0.x | 10 +++++ ci/Gemfile.rails-4.0.x.lock | 37 +++++++++++++++++++ ci/Gemfile.rails-4.1.x | 10 +++++ ci/Gemfile.rails-4.1.x.lock | 37 +++++++++++++++++++ 16 files changed, 222 insertions(+), 1 deletion(-) rename ci/{Gemfile.rails-3.x => Gemfile.rails-3.0.x} (86%) rename ci/{Gemfile.rails-3.x.lock => Gemfile.rails-3.0.x.lock} (87%) create mode 100644 ci/Gemfile.rails-3.1.x create mode 100644 ci/Gemfile.rails-3.1.x.lock create mode 100644 ci/Gemfile.rails-3.2.x create mode 100644 ci/Gemfile.rails-3.2.x.lock create mode 100644 ci/Gemfile.rails-4.0.x create mode 100644 ci/Gemfile.rails-4.0.x.lock create mode 100644 ci/Gemfile.rails-4.1.x create mode 100644 ci/Gemfile.rails-4.1.x.lock diff --git a/.travis.yml b/.travis.yml index 7f12de54..18b0c603 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,11 @@ rvm: gemfile: - ci/Gemfile.no-rails - ci/Gemfile.rails-2.3.x - - ci/Gemfile.rails-3.x + - ci/Gemfile.rails-3.0.x + - ci/Gemfile.rails-3.1.x + - ci/Gemfile.rails-3.2.x + - ci/Gemfile.rails-4.0.x + - ci/Gemfile.rails-4.1.x matrix: allow_failures: @@ -29,4 +33,16 @@ matrix: rvm: rbx - gemfile: ci/Gemfile.rails-2.3.x rvm: jruby + - gemfile: ci/Gemfile.rails-4.0.x + rvm: 1.8.7 + - gemfile: ci/Gemfile.rails-4.0.x + rvm: 1.9.2 + - gemfile: ci/Gemfile.rails-4.0.x + rvm: ree + - gemfile: ci/Gemfile.rails-4.1.x + rvm: 1.8.7 + - gemfile: ci/Gemfile.rails-4.1.x + rvm: 1.9.2 + - gemfile: ci/Gemfile.rails-4.1.x + rvm: ree fast_finish: true diff --git a/Gemfile.lock b/Gemfile.lock index 6e05287b..eef0e235 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,8 @@ +PATH + remote: . + specs: + i18n (0.6.9) + GEM remote: https://rubygems.org/ specs: @@ -12,6 +17,7 @@ PLATFORMS ruby DEPENDENCIES + i18n! mocha rake test_declarative diff --git a/ci/Gemfile.no-rails b/ci/Gemfile.no-rails index 4efc15e6..734cc6b7 100644 --- a/ci/Gemfile.no-rails +++ b/ci/Gemfile.no-rails @@ -1,5 +1,7 @@ source 'https://rubygems.org' +gemspec :path => '..' + gem 'mocha' gem 'test_declarative' gem 'rake' diff --git a/ci/Gemfile.no-rails.lock b/ci/Gemfile.no-rails.lock index ecd59534..280c8ae8 100644 --- a/ci/Gemfile.no-rails.lock +++ b/ci/Gemfile.no-rails.lock @@ -1,3 +1,8 @@ +PATH + remote: .. + specs: + i18n (0.6.9) + GEM remote: https://rubygems.org/ specs: @@ -11,6 +16,7 @@ PLATFORMS ruby DEPENDENCIES + i18n! mocha rake test_declarative diff --git a/ci/Gemfile.rails-2.3.x b/ci/Gemfile.rails-2.3.x index 15c6f531..b0b1fa11 100644 --- a/ci/Gemfile.rails-2.3.x +++ b/ci/Gemfile.rails-2.3.x @@ -1,5 +1,7 @@ source 'https://rubygems.org' +gemspec :path => '..' + gem 'activesupport', '~> 2.3' gem 'mocha' gem 'test_declarative' diff --git a/ci/Gemfile.rails-2.3.x.lock b/ci/Gemfile.rails-2.3.x.lock index 3a7d69da..d56b2e10 100644 --- a/ci/Gemfile.rails-2.3.x.lock +++ b/ci/Gemfile.rails-2.3.x.lock @@ -1,3 +1,8 @@ +PATH + remote: .. + specs: + i18n (0.6.9) + GEM remote: https://rubygems.org/ specs: @@ -17,6 +22,7 @@ PLATFORMS DEPENDENCIES activesupport (~> 2.3) ffi + i18n! mocha rake rufus-tokyo diff --git a/ci/Gemfile.rails-3.x b/ci/Gemfile.rails-3.0.x similarity index 86% rename from ci/Gemfile.rails-3.x rename to ci/Gemfile.rails-3.0.x index 83006003..59fcf0e3 100644 --- a/ci/Gemfile.rails-3.x +++ b/ci/Gemfile.rails-3.0.x @@ -1,5 +1,7 @@ source 'https://rubygems.org' +gemspec :path => '..' + gem 'activesupport', '~> 3.0.0' gem 'mocha' gem 'test_declarative' diff --git a/ci/Gemfile.rails-3.x.lock b/ci/Gemfile.rails-3.0.x.lock similarity index 87% rename from ci/Gemfile.rails-3.x.lock rename to ci/Gemfile.rails-3.0.x.lock index 6d27cee7..49f4a9ea 100644 --- a/ci/Gemfile.rails-3.x.lock +++ b/ci/Gemfile.rails-3.0.x.lock @@ -1,3 +1,8 @@ +PATH + remote: .. + specs: + i18n (0.6.9) + GEM remote: https://rubygems.org/ specs: @@ -17,6 +22,7 @@ PLATFORMS DEPENDENCIES activesupport (~> 3.0.0) ffi + i18n! mocha rake rufus-tokyo diff --git a/ci/Gemfile.rails-3.1.x b/ci/Gemfile.rails-3.1.x new file mode 100644 index 00000000..98174c4f --- /dev/null +++ b/ci/Gemfile.rails-3.1.x @@ -0,0 +1,10 @@ +source 'https://rubygems.org' + +gemspec :path => '..' + +gem 'activesupport', '~> 3.1.0' +gem 'mocha' +gem 'test_declarative' +gem 'rufus-tokyo' +gem 'ffi' +gem 'rake' diff --git a/ci/Gemfile.rails-3.1.x.lock b/ci/Gemfile.rails-3.1.x.lock new file mode 100644 index 00000000..cd380db1 --- /dev/null +++ b/ci/Gemfile.rails-3.1.x.lock @@ -0,0 +1,30 @@ +PATH + remote: .. + specs: + i18n (0.6.9) + +GEM + remote: https://rubygems.org/ + specs: + activesupport (3.1.12) + multi_json (~> 1.0) + ffi (1.9.3) + metaclass (0.0.4) + mocha (1.0.0) + metaclass (~> 0.0.1) + multi_json (1.10.0) + rake (10.3.1) + rufus-tokyo (1.0.7) + test_declarative (0.0.5) + +PLATFORMS + ruby + +DEPENDENCIES + activesupport (~> 3.1.0) + ffi + i18n! + mocha + rake + rufus-tokyo + test_declarative diff --git a/ci/Gemfile.rails-3.2.x b/ci/Gemfile.rails-3.2.x new file mode 100644 index 00000000..0aed63be --- /dev/null +++ b/ci/Gemfile.rails-3.2.x @@ -0,0 +1,10 @@ +source 'https://rubygems.org' + +gemspec :path => '..' + +gem 'activesupport', '~> 3.2.0' +gem 'mocha' +gem 'test_declarative' +gem 'rufus-tokyo' +gem 'ffi' +gem 'rake' diff --git a/ci/Gemfile.rails-3.2.x.lock b/ci/Gemfile.rails-3.2.x.lock new file mode 100644 index 00000000..9425642d --- /dev/null +++ b/ci/Gemfile.rails-3.2.x.lock @@ -0,0 +1,31 @@ +PATH + remote: .. + specs: + i18n (0.6.9) + +GEM + remote: https://rubygems.org/ + specs: + activesupport (3.2.18) + i18n (~> 0.6, >= 0.6.4) + multi_json (~> 1.0) + ffi (1.9.3) + metaclass (0.0.4) + mocha (1.0.0) + metaclass (~> 0.0.1) + multi_json (1.10.0) + rake (10.3.1) + rufus-tokyo (1.0.7) + test_declarative (0.0.5) + +PLATFORMS + ruby + +DEPENDENCIES + activesupport (~> 3.2.0) + ffi + i18n! + mocha + rake + rufus-tokyo + test_declarative diff --git a/ci/Gemfile.rails-4.0.x b/ci/Gemfile.rails-4.0.x new file mode 100644 index 00000000..ac0793d0 --- /dev/null +++ b/ci/Gemfile.rails-4.0.x @@ -0,0 +1,10 @@ +source 'https://rubygems.org' + +gemspec :path => '..' + +gem 'activesupport', '~> 4.0.0' +gem 'mocha' +gem 'test_declarative' +gem 'rufus-tokyo' +gem 'ffi' +gem 'rake' diff --git a/ci/Gemfile.rails-4.0.x.lock b/ci/Gemfile.rails-4.0.x.lock new file mode 100644 index 00000000..09eefb62 --- /dev/null +++ b/ci/Gemfile.rails-4.0.x.lock @@ -0,0 +1,37 @@ +PATH + remote: .. + specs: + i18n (0.6.9) + +GEM + remote: https://rubygems.org/ + specs: + activesupport (4.0.5) + i18n (~> 0.6, >= 0.6.9) + minitest (~> 4.2) + multi_json (~> 1.3) + thread_safe (~> 0.1) + tzinfo (~> 0.3.37) + ffi (1.9.3) + metaclass (0.0.4) + minitest (4.7.5) + mocha (1.0.0) + metaclass (~> 0.0.1) + multi_json (1.10.0) + rake (10.3.1) + rufus-tokyo (1.0.7) + test_declarative (0.0.5) + thread_safe (0.3.3) + tzinfo (0.3.39) + +PLATFORMS + ruby + +DEPENDENCIES + activesupport (~> 4.0.0) + ffi + i18n! + mocha + rake + rufus-tokyo + test_declarative diff --git a/ci/Gemfile.rails-4.1.x b/ci/Gemfile.rails-4.1.x new file mode 100644 index 00000000..ac0793d0 --- /dev/null +++ b/ci/Gemfile.rails-4.1.x @@ -0,0 +1,10 @@ +source 'https://rubygems.org' + +gemspec :path => '..' + +gem 'activesupport', '~> 4.0.0' +gem 'mocha' +gem 'test_declarative' +gem 'rufus-tokyo' +gem 'ffi' +gem 'rake' diff --git a/ci/Gemfile.rails-4.1.x.lock b/ci/Gemfile.rails-4.1.x.lock new file mode 100644 index 00000000..09eefb62 --- /dev/null +++ b/ci/Gemfile.rails-4.1.x.lock @@ -0,0 +1,37 @@ +PATH + remote: .. + specs: + i18n (0.6.9) + +GEM + remote: https://rubygems.org/ + specs: + activesupport (4.0.5) + i18n (~> 0.6, >= 0.6.9) + minitest (~> 4.2) + multi_json (~> 1.3) + thread_safe (~> 0.1) + tzinfo (~> 0.3.37) + ffi (1.9.3) + metaclass (0.0.4) + minitest (4.7.5) + mocha (1.0.0) + metaclass (~> 0.0.1) + multi_json (1.10.0) + rake (10.3.1) + rufus-tokyo (1.0.7) + test_declarative (0.0.5) + thread_safe (0.3.3) + tzinfo (0.3.39) + +PLATFORMS + ruby + +DEPENDENCIES + activesupport (~> 4.0.0) + ffi + i18n! + mocha + rake + rufus-tokyo + test_declarative From aac5ab7e21be2bef8d1ab379ffa4f587f0d4876b Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Tue, 6 May 2014 20:19:06 -0300 Subject: [PATCH 032/145] Remove Ruby 1.9.2 from travis I seriously hope no one is using this version in production. --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 18b0c603..de42d014 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ before_install: "sudo apt-get install ruby-tokyocabinet -y" rvm: - 1.8.7 - - 1.9.2 - 1.9.3 - 2.0.0 - 2.1.1 From c53d4ea4fcac720d0a8e12044afc4e90846d454c Mon Sep 17 00:00:00 2001 From: Juanito Fatas Date: Mon, 9 Sep 2013 13:51:01 +0800 Subject: [PATCH 033/145] Change README to markdown [ci skip] Closes #217 --- README.textile => README.md | 54 ++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 27 deletions(-) rename README.textile => README.md (68%) diff --git a/README.textile b/README.md similarity index 68% rename from README.textile rename to README.md index 57b79c10..9f638eea 100644 --- a/README.textile +++ b/README.md @@ -1,6 +1,6 @@ -h1. Ruby I18n +# Ruby I18n -!https://secure.travis-ci.org/svenfuchs/i18n.png?branch=master(Build Status)!:http://travis-ci.org/svenfuchs/i18n +![Build Status](https://secure.travis-ci.org/svenfuchs/i18n.png?branch=master) Ruby Internationalization and localization solution. @@ -31,37 +31,37 @@ Alternative backends: * ActiveRecord (optionally: ActiveRecord::Missing and ActiveRecord::StoreProcs) * KeyValue (uses active_support/json and cannot store procs) -For more information and lots of resources see: "http://ruby-i18n.org/wiki":http://ruby-i18n.org/wiki +For more information and lots of resources see: [http://ruby-i18n.org/wiki](http://ruby-i18n.org/wiki) -h2. Installation +## Installation gem install i18n -h4. Rails version warning +#### Rails version warning -On Rails < 2.3.6 the method I18n.localize will fail with MissingInterpolationArgument (issue "20":http://github.com/svenfuchs/i18n/issues/issue/20). Upgrade to Rails 2.3.6 or higher (2.3.8 preferably) is recommended. +On Rails < 2.3.6 the method I18n.localize will fail with MissingInterpolationArgument (issue [20](http://github.com/svenfuchs/i18n/issues/issue/20). Upgrade to Rails 2.3.6 or higher (2.3.8 preferably) is recommended. -h3. Installation on Rails < 2.3.5 (deprecated) +### Installation on Rails < 2.3.5 (deprecated) Up to version 2.3.4 Rails will not accept i18n gems > 0.1.3. There is an unpacked -gem inside of active_support/lib/vendor which gets loaded unless gem 'i18n', '~> 0.1.3'. -This requirement is relaxed in "6da03653":http://github.com/rails/rails/commit/6da03653 +gem inside of active_support/lib/vendor which gets loaded unless `gem 'i18n', '~> 0.1.3'`. +This requirement is relaxed in [6da03653](http://github.com/rails/rails/commit/6da03653) The new i18n gem can be loaded from vendor/plugins like this: -
-  def reload_i18n!
-    raise "Move to i18n version 0.2.0 or greater" if Rails.version > "2.3.4"
+```
+def reload_i18n!
+  raise "Move to i18n version 0.2.0 or greater" if Rails.version > "2.3.4"
 
-    $:.grep(/i18n/).each { |path| $:.delete(path) }
-    I18n::Backend.send :remove_const, "Simple"
-    $: << Rails.root.join('vendor', 'plugins', 'i18n', 'lib').to_s
-  end
-
+ $:.grep(/i18n/).each { |path| $:.delete(path) } + I18n::Backend.send :remove_const, "Simple" + $: << Rails.root.join('vendor', 'plugins', 'i18n', 'lib').to_s +end +``` Then you can `reload_i18n!` inside an i18n initializer. -h2. Tests +## Tests You can run tests both with @@ -85,21 +85,21 @@ as test methods) in test cases with different setups. You can find the test cases that enforce the API in test/api. And you can find the API definition test methods in test/api/tests. -All other test cases (e.g. as defined in test/backend, test/core\_ext) etc. +All other test cases (e.g. as defined in test/backend, test/core_ext) etc. follow the usual test setup and should be easy to grok. -h2. Authors +## Authors -* "Sven Fuchs":http://www.artweb-design.de -* "Joshua Harvey":http://www.workingwithrails.com/person/759-joshua-harvey -* "Stephan Soller":http://www.arkanis-development.de -* "Saimon Moore":http://saimonmoore.net -* "Matt Aimonetti":http://railsontherun.com +* [Sven Fuchs](http://www.artweb-design.de) +* [Joshua Harvey](http://www.workingwithrails.com/person/759-joshua-harvey) +* [Stephan Soller](http://www.arkanis-development.de) +* [Saimon Moore](http://saimonmoore.net) +* [Matt Aimonetti](http://railsontherun.com) -h2. Contributors +## Contributors http://github.com/svenfuchs/i18n/contributors -h2. License +## License MIT License. See the included MIT-LICENSE file. From 011979537338a60fbd89bcc5bfabb8d414eec82a Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Tue, 6 May 2014 22:06:42 -0300 Subject: [PATCH 034/145] Update gemspec with new README in markdown [ci skip] --- i18n.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18n.gemspec b/i18n.gemspec index 9a4a4de5..f4530698 100644 --- a/i18n.gemspec +++ b/i18n.gemspec @@ -13,7 +13,7 @@ Gem::Specification.new do |s| s.description = "New wave Internationalization support for Ruby." s.license = "MIT" - s.files = Dir.glob("{ci,lib,test}/**/**") + %w(README.textile MIT-LICENSE) + s.files = Dir.glob("{ci,lib,test}/**/**") + %w(README.md MIT-LICENSE) s.platform = Gem::Platform::RUBY s.require_path = 'lib' s.rubyforge_project = '[none]' From 0eae756c298f6771869de4eca61604a19b7bfb69 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Tue, 6 May 2014 22:58:23 -0300 Subject: [PATCH 035/145] Remove dead code [ci skip] --- Rakefile | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/Rakefile b/Rakefile index 94036070..ab8cc969 100644 --- a/Rakefile +++ b/Rakefile @@ -10,18 +10,3 @@ Rake::TestTask.new(:test) do |t| t.warning = true end Rake::Task['test'].comment = "Run all i18n tests" - -# require "rake/gempackagetask" -# require "rake/clean" -# CLEAN << "pkg" << "doc" << "coverage" << ".yardoc" -# -# Rake::GemPackageTask.new(eval(File.read("i18n.gemspec"))) { |pkg| } -# -# begin -# require "yard" -# YARD::Rake::YardocTask.new do |t| -# t.options = ["--output-dir=doc"] -# t.options << "--files" << ["CHANGELOG.textile", "contributors.txt", "MIT-LICENSE"].join(",") -# end -# rescue LoadError -# end From 279d94af1fccb425aac0029bcf63128f2d257982 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Tue, 6 May 2014 23:46:05 -0300 Subject: [PATCH 036/145] Stop symlinking the Gemfile Just have the file in the root as expected, and keep the others we need under ci/. --- .travis.yml | 2 +- Gemfile | 8 +++++++- ci/Gemfile.no-rails | 7 ------- 3 files changed, 8 insertions(+), 9 deletions(-) mode change 120000 => 100644 Gemfile delete mode 100644 ci/Gemfile.no-rails diff --git a/.travis.yml b/.travis.yml index de42d014..d568e31c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ rvm: - jruby gemfile: - - ci/Gemfile.no-rails + - Gemfile - ci/Gemfile.rails-2.3.x - ci/Gemfile.rails-3.0.x - ci/Gemfile.rails-3.1.x diff --git a/Gemfile b/Gemfile deleted file mode 120000 index bcfd9a12..00000000 --- a/Gemfile +++ /dev/null @@ -1 +0,0 @@ -ci/Gemfile.no-rails \ No newline at end of file diff --git a/Gemfile b/Gemfile new file mode 100644 index 00000000..24ca9f45 --- /dev/null +++ b/Gemfile @@ -0,0 +1,7 @@ +source 'https://rubygems.org' + +gemspec + +gem 'mocha' +gem 'test_declarative' +gem 'rake' diff --git a/ci/Gemfile.no-rails b/ci/Gemfile.no-rails deleted file mode 100644 index 734cc6b7..00000000 --- a/ci/Gemfile.no-rails +++ /dev/null @@ -1,7 +0,0 @@ -source 'https://rubygems.org' - -gemspec :path => '..' - -gem 'mocha' -gem 'test_declarative' -gem 'rake' From 5e8e50f53348e4256104b1fe90397df4dfd9bfc6 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Tue, 6 May 2014 23:48:43 -0300 Subject: [PATCH 037/145] Move all Gemfiles to "gemfiles" folder This is a more commonly used name, according to the docs: http://docs.travis-ci.com/user/languages/ruby/ --- .travis.yml | 32 +++++++++++------------ {ci => gemfiles}/Gemfile.no-rails.lock | 0 {ci => gemfiles}/Gemfile.rails-2.3.x | 0 {ci => gemfiles}/Gemfile.rails-2.3.x.lock | 0 {ci => gemfiles}/Gemfile.rails-3.0.x | 0 {ci => gemfiles}/Gemfile.rails-3.0.x.lock | 0 {ci => gemfiles}/Gemfile.rails-3.1.x | 0 {ci => gemfiles}/Gemfile.rails-3.1.x.lock | 0 {ci => gemfiles}/Gemfile.rails-3.2.x | 0 {ci => gemfiles}/Gemfile.rails-3.2.x.lock | 0 {ci => gemfiles}/Gemfile.rails-4.0.x | 0 {ci => gemfiles}/Gemfile.rails-4.0.x.lock | 0 {ci => gemfiles}/Gemfile.rails-4.1.x | 0 {ci => gemfiles}/Gemfile.rails-4.1.x.lock | 0 i18n.gemspec | 2 +- test/run_all.rb | 2 +- 16 files changed, 18 insertions(+), 18 deletions(-) rename {ci => gemfiles}/Gemfile.no-rails.lock (100%) rename {ci => gemfiles}/Gemfile.rails-2.3.x (100%) rename {ci => gemfiles}/Gemfile.rails-2.3.x.lock (100%) rename {ci => gemfiles}/Gemfile.rails-3.0.x (100%) rename {ci => gemfiles}/Gemfile.rails-3.0.x.lock (100%) rename {ci => gemfiles}/Gemfile.rails-3.1.x (100%) rename {ci => gemfiles}/Gemfile.rails-3.1.x.lock (100%) rename {ci => gemfiles}/Gemfile.rails-3.2.x (100%) rename {ci => gemfiles}/Gemfile.rails-3.2.x.lock (100%) rename {ci => gemfiles}/Gemfile.rails-4.0.x (100%) rename {ci => gemfiles}/Gemfile.rails-4.0.x.lock (100%) rename {ci => gemfiles}/Gemfile.rails-4.1.x (100%) rename {ci => gemfiles}/Gemfile.rails-4.1.x.lock (100%) diff --git a/.travis.yml b/.travis.yml index d568e31c..cf58debc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,12 +11,12 @@ rvm: gemfile: - Gemfile - - ci/Gemfile.rails-2.3.x - - ci/Gemfile.rails-3.0.x - - ci/Gemfile.rails-3.1.x - - ci/Gemfile.rails-3.2.x - - ci/Gemfile.rails-4.0.x - - ci/Gemfile.rails-4.1.x + - gemfiles/Gemfile.rails-2.3.x + - gemfiles/Gemfile.rails-3.0.x + - gemfiles/Gemfile.rails-3.1.x + - gemfiles/Gemfile.rails-3.2.x + - gemfiles/Gemfile.rails-4.0.x + - gemfiles/Gemfile.rails-4.1.x matrix: allow_failures: @@ -24,24 +24,24 @@ matrix: - rvm: rbx - rvm: jruby exclude: - - gemfile: ci/Gemfile.rails-2.3.x + - gemfile: gemfiles/Gemfile.rails-2.3.x rvm: 2.0.0 - - gemfile: ci/Gemfile.rails-2.3.x + - gemfile: gemfiles/Gemfile.rails-2.3.x rvm: 2.1.1 - - gemfile: ci/Gemfile.rails-2.3.x + - gemfile: gemfiles/Gemfile.rails-2.3.x rvm: rbx - - gemfile: ci/Gemfile.rails-2.3.x + - gemfile: gemfiles/Gemfile.rails-2.3.x rvm: jruby - - gemfile: ci/Gemfile.rails-4.0.x + - gemfile: gemfiles/Gemfile.rails-4.0.x rvm: 1.8.7 - - gemfile: ci/Gemfile.rails-4.0.x + - gemfile: gemfiles/Gemfile.rails-4.0.x rvm: 1.9.2 - - gemfile: ci/Gemfile.rails-4.0.x + - gemfile: gemfiles/Gemfile.rails-4.0.x rvm: ree - - gemfile: ci/Gemfile.rails-4.1.x + - gemfile: gemfiles/Gemfile.rails-4.1.x rvm: 1.8.7 - - gemfile: ci/Gemfile.rails-4.1.x + - gemfile: gemfiles/Gemfile.rails-4.1.x rvm: 1.9.2 - - gemfile: ci/Gemfile.rails-4.1.x + - gemfile: gemfiles/Gemfile.rails-4.1.x rvm: ree fast_finish: true diff --git a/ci/Gemfile.no-rails.lock b/gemfiles/Gemfile.no-rails.lock similarity index 100% rename from ci/Gemfile.no-rails.lock rename to gemfiles/Gemfile.no-rails.lock diff --git a/ci/Gemfile.rails-2.3.x b/gemfiles/Gemfile.rails-2.3.x similarity index 100% rename from ci/Gemfile.rails-2.3.x rename to gemfiles/Gemfile.rails-2.3.x diff --git a/ci/Gemfile.rails-2.3.x.lock b/gemfiles/Gemfile.rails-2.3.x.lock similarity index 100% rename from ci/Gemfile.rails-2.3.x.lock rename to gemfiles/Gemfile.rails-2.3.x.lock diff --git a/ci/Gemfile.rails-3.0.x b/gemfiles/Gemfile.rails-3.0.x similarity index 100% rename from ci/Gemfile.rails-3.0.x rename to gemfiles/Gemfile.rails-3.0.x diff --git a/ci/Gemfile.rails-3.0.x.lock b/gemfiles/Gemfile.rails-3.0.x.lock similarity index 100% rename from ci/Gemfile.rails-3.0.x.lock rename to gemfiles/Gemfile.rails-3.0.x.lock diff --git a/ci/Gemfile.rails-3.1.x b/gemfiles/Gemfile.rails-3.1.x similarity index 100% rename from ci/Gemfile.rails-3.1.x rename to gemfiles/Gemfile.rails-3.1.x diff --git a/ci/Gemfile.rails-3.1.x.lock b/gemfiles/Gemfile.rails-3.1.x.lock similarity index 100% rename from ci/Gemfile.rails-3.1.x.lock rename to gemfiles/Gemfile.rails-3.1.x.lock diff --git a/ci/Gemfile.rails-3.2.x b/gemfiles/Gemfile.rails-3.2.x similarity index 100% rename from ci/Gemfile.rails-3.2.x rename to gemfiles/Gemfile.rails-3.2.x diff --git a/ci/Gemfile.rails-3.2.x.lock b/gemfiles/Gemfile.rails-3.2.x.lock similarity index 100% rename from ci/Gemfile.rails-3.2.x.lock rename to gemfiles/Gemfile.rails-3.2.x.lock diff --git a/ci/Gemfile.rails-4.0.x b/gemfiles/Gemfile.rails-4.0.x similarity index 100% rename from ci/Gemfile.rails-4.0.x rename to gemfiles/Gemfile.rails-4.0.x diff --git a/ci/Gemfile.rails-4.0.x.lock b/gemfiles/Gemfile.rails-4.0.x.lock similarity index 100% rename from ci/Gemfile.rails-4.0.x.lock rename to gemfiles/Gemfile.rails-4.0.x.lock diff --git a/ci/Gemfile.rails-4.1.x b/gemfiles/Gemfile.rails-4.1.x similarity index 100% rename from ci/Gemfile.rails-4.1.x rename to gemfiles/Gemfile.rails-4.1.x diff --git a/ci/Gemfile.rails-4.1.x.lock b/gemfiles/Gemfile.rails-4.1.x.lock similarity index 100% rename from ci/Gemfile.rails-4.1.x.lock rename to gemfiles/Gemfile.rails-4.1.x.lock diff --git a/i18n.gemspec b/i18n.gemspec index f4530698..9feefe41 100644 --- a/i18n.gemspec +++ b/i18n.gemspec @@ -13,7 +13,7 @@ Gem::Specification.new do |s| s.description = "New wave Internationalization support for Ruby." s.license = "MIT" - s.files = Dir.glob("{ci,lib,test}/**/**") + %w(README.md MIT-LICENSE) + s.files = Dir.glob("{gemfiles,lib,test}/**/**") + %w(README.md MIT-LICENSE) s.platform = Gem::Platform::RUBY s.require_path = 'lib' s.rubyforge_project = '[none]' diff --git a/test/run_all.rb b/test/run_all.rb index 0c31db7c..4c37bb42 100644 --- a/test/run_all.rb +++ b/test/run_all.rb @@ -3,7 +3,7 @@ def bundle_check end command = 'ruby -w -Ilib -Itest test/all.rb' -gemfiles = %w(ci/Gemfile.rails-3.x ci/Gemfile.rails-2.3.x ci/Gemfile.no-rails) +gemfiles = %w(gemfiles/Gemfile.rails-3.x gemfiles/Gemfile.rails-2.3.x gemfiles/Gemfile.no-rails) results = gemfiles.map do |gemfile| puts "BUNDLE_GEMFILE=#{gemfile}" From 5749667dee3eaad9126e24f68d004f13a20175ad Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Tue, 6 May 2014 23:56:44 -0300 Subject: [PATCH 038/145] Fix script that runs tests against all available Gemfiles BUNDLE_GEMFILE needs the full path to work properly. Load all custom Gemfiles rather than a fixed list, so adding/removing files from the gemfiles/ folder just works. --- test/run_all.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/run_all.rb b/test/run_all.rb index 4c37bb42..cda7c488 100644 --- a/test/run_all.rb +++ b/test/run_all.rb @@ -3,11 +3,11 @@ def bundle_check end command = 'ruby -w -Ilib -Itest test/all.rb' -gemfiles = %w(gemfiles/Gemfile.rails-3.x gemfiles/Gemfile.rails-2.3.x gemfiles/Gemfile.no-rails) +gemfiles = %w(Gemfile) + Dir['gemfiles/Gemfile*'].reject { |f| f.end_with?('.lock') } results = gemfiles.map do |gemfile| puts "BUNDLE_GEMFILE=#{gemfile}" - ENV['BUNDLE_GEMFILE'] = gemfile + ENV['BUNDLE_GEMFILE'] = File.expand_path("../../#{gemfile}", __FILE__) unless bundle_check puts "bundle install" @@ -15,7 +15,7 @@ def bundle_check end puts command - system('ruby -w -Ilib -Itest test/all.rb') + system command end exit(results.inject(true) { |a, b| a && b }) From 7a8489db3941b4ff7aadf5a4f17933367101398f Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Wed, 7 May 2014 00:06:39 -0300 Subject: [PATCH 039/145] Fix example locale file for benchmark with newer yml --- benchmark/example.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/benchmark/example.yml b/benchmark/example.yml index da5f9fe7..650c3905 100644 --- a/benchmark/example.yml +++ b/benchmark/example.yml @@ -60,7 +60,10 @@ en: month_names: [~, January, February, March, April, May, June, July, August, September, October, November, December] abbr_month_names: [~, Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec] # Used in date_select and datime_select. - order: [ :year, :month, :day ] + order: + - :year, + - :month, + - :day time: formats: @@ -131,7 +134,10 @@ en: month_names: [~, January, February, March, April, May, June, July, August, September, October, November, December] abbr_month_names: [~, Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec] # Used in date_select and datime_select. - order: [ :year, :month, :day ] + order: + - :year + - :month + - :day time: formats: @@ -145,4 +151,4 @@ en: array: words_connector: ", " two_words_connector: " and " - last_word_connector: ", and " \ No newline at end of file + last_word_connector: ", and " From 3f30eb4dc3d70dd3077d8b9867cee959f44ed38f Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Wed, 7 May 2014 08:44:46 -0300 Subject: [PATCH 040/145] Nodoc and document new internal method [ci skip] Also improve docs on enforce available locale related methods. --- lib/i18n.rb | 9 +++------ lib/i18n/config.rb | 4 +++- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/i18n.rb b/lib/i18n.rb index 7e492a59..98b65bf3 100644 --- a/lib/i18n.rb +++ b/lib/i18n.rb @@ -271,16 +271,13 @@ def normalize_keys(locale, key, scope, separator = nil) keys end - # Returns true when the passed locale is in I18.available_locales. - # Returns false otherwise. - # Compare with Strings as `locale` may be coming from user input + # Returns true when the passed locale, which can be either a String or a + # Symbol, is in the list of available locales. Returns false otherwise. def locale_available?(locale) I18n.config.available_locales_set.include?(locale) end - # Raises an InvalidLocale exception when the passed locale is not - # included in I18n.available_locales. - # Returns false otherwise + # Raises an InvalidLocale exception when the passed locale is not available. def enforce_available_locales!(locale) handle_enforce_available_locales_deprecation diff --git a/lib/i18n/config.rb b/lib/i18n/config.rb index 3fc8a615..b5750bd4 100644 --- a/lib/i18n/config.rb +++ b/lib/i18n/config.rb @@ -41,7 +41,9 @@ def available_locales @@available_locales || backend.available_locales end - def available_locales_set + # Caches the available locales list as both strings and symbols in a Set, so + # that we can have faster lookups to do the available locales enforce check. + def available_locales_set #:nodoc: @@available_locales_set ||= available_locales.inject(Set.new) do |set, locale| set << locale.to_s << locale.to_sym end From 192b0ff63c2ae46addacc651be509e44fae48c2b Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Wed, 7 May 2014 08:47:32 -0300 Subject: [PATCH 041/145] Fix bundle check guard clause on run_all script So that it does not need to run bundle install all the time. --- test/run_all.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/run_all.rb b/test/run_all.rb index cda7c488..80c807ed 100644 --- a/test/run_all.rb +++ b/test/run_all.rb @@ -1,5 +1,5 @@ def bundle_check - `bundle check` == "The Gemfile's dependencies are satisfied\n" + `bundle check` == "Resolving dependencies...\nThe Gemfile's dependencies are satisfied\n" end command = 'ruby -w -Ilib -Itest test/all.rb' From 8bb956a52f4fafb4ca15c7ae57cf9f67797e67fb Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Thu, 8 May 2014 16:39:02 -0300 Subject: [PATCH 042/145] Remove missed lock file [ci skip] --- gemfiles/Gemfile.no-rails.lock | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 gemfiles/Gemfile.no-rails.lock diff --git a/gemfiles/Gemfile.no-rails.lock b/gemfiles/Gemfile.no-rails.lock deleted file mode 100644 index 280c8ae8..00000000 --- a/gemfiles/Gemfile.no-rails.lock +++ /dev/null @@ -1,22 +0,0 @@ -PATH - remote: .. - specs: - i18n (0.6.9) - -GEM - remote: https://rubygems.org/ - specs: - metaclass (0.0.4) - mocha (1.0.0) - metaclass (~> 0.0.1) - rake (10.3.1) - test_declarative (0.0.5) - -PLATFORMS - ruby - -DEPENDENCIES - i18n! - mocha - rake - test_declarative From a4f451b45e13e53600a68151dfab6d9b5db84e3a Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Thu, 8 May 2014 20:45:37 -0300 Subject: [PATCH 043/145] Remove Ruby 1.9.2 entries from travis exclude options [ci skip] --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index cf58debc..075fc585 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,14 +34,10 @@ matrix: rvm: jruby - gemfile: gemfiles/Gemfile.rails-4.0.x rvm: 1.8.7 - - gemfile: gemfiles/Gemfile.rails-4.0.x - rvm: 1.9.2 - gemfile: gemfiles/Gemfile.rails-4.0.x rvm: ree - gemfile: gemfiles/Gemfile.rails-4.1.x rvm: 1.8.7 - - gemfile: gemfiles/Gemfile.rails-4.1.x - rvm: 1.9.2 - gemfile: gemfiles/Gemfile.rails-4.1.x rvm: ree fast_finish: true From f871057b496ea596762b596cc7fe23f5a78cf484 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Thu, 8 May 2014 20:50:33 -0300 Subject: [PATCH 044/145] Get rid of test warning warning: (...) interpreted as grouped expression --- test/i18n_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/i18n_test.rb b/test/i18n_test.rb index 0c18f287..fd7e5ea8 100644 --- a/test/i18n_test.rb +++ b/test/i18n_test.rb @@ -229,7 +229,7 @@ def setup test "available_locales_set should return a set" do assert_equal Set, I18n.config.available_locales_set.class - assert_equal (I18n.config.available_locales.size * 2), I18n.config.available_locales_set.size + assert_equal I18n.config.available_locales.size * 2, I18n.config.available_locales_set.size end test "exists? given an existing key will return true" do From 38f7d53209207613f61e77278282185807e50758 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Fri, 9 May 2014 10:09:13 -0300 Subject: [PATCH 045/145] Use bundle exec when running tests for all gemfiles Refactor script a bit, improve output. --- test/run_all.rb | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/test/run_all.rb b/test/run_all.rb index 80c807ed..46bc43c3 100644 --- a/test/run_all.rb +++ b/test/run_all.rb @@ -2,20 +2,19 @@ def bundle_check `bundle check` == "Resolving dependencies...\nThe Gemfile's dependencies are satisfied\n" end -command = 'ruby -w -Ilib -Itest test/all.rb' +def execute(command) + puts command + system command +end + gemfiles = %w(Gemfile) + Dir['gemfiles/Gemfile*'].reject { |f| f.end_with?('.lock') } results = gemfiles.map do |gemfile| - puts "BUNDLE_GEMFILE=#{gemfile}" + puts "\nBUNDLE_GEMFILE=#{gemfile}" ENV['BUNDLE_GEMFILE'] = File.expand_path("../../#{gemfile}", __FILE__) - unless bundle_check - puts "bundle install" - system('bundle install') - end - - puts command - system command + execute 'bundle install' unless bundle_check + execute 'bundle exec ruby -w -Ilib -Itest test/all.rb' end -exit(results.inject(true) { |a, b| a && b }) +exit results.all? From 706bcbf29ee9723b33a278d1c37aeaf3333e868e Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Fri, 9 May 2014 08:13:58 -0300 Subject: [PATCH 046/145] Create our own TestCase class to add methods Rather than extending the base Test::Unit::TestCase, simply create our own test case and add methods to it, and make sure we inherit from this new test case everywhere. Also make sure to call `super` on the teardown method. --- test/api/all_features_test.rb | 2 +- test/api/cascade_test.rb | 2 +- test/api/chain_test.rb | 2 +- test/api/fallbacks_test.rb | 2 +- test/api/key_value_test.rb | 4 +-- test/api/memoize_test.rb | 6 ++--- test/api/override_test.rb | 7 +----- test/api/pluralization_test.rb | 2 +- test/api/simple_test.rb | 2 +- test/backend/cache_test.rb | 2 +- test/backend/cascade_test.rb | 2 +- test/backend/chain_test.rb | 2 +- test/backend/exceptions_test.rb | 2 +- test/backend/fallbacks_test.rb | 8 +++--- test/backend/interpolation_compiler_test.rb | 4 +-- test/backend/key_value_test.rb | 4 +-- test/backend/metadata_test.rb | 2 +- test/backend/pluralization_test.rb | 2 +- test/backend/simple_test.rb | 2 +- test/backend/transliterator_test.rb | 2 +- test/core_ext/hash_test.rb | 2 +- test/core_ext/string/interpolate_test.rb | 2 +- test/gettext/api_test.rb | 2 +- test/gettext/backend_test.rb | 2 +- test/i18n/exceptions_test.rb | 2 +- test/i18n/interpolate_test.rb | 4 +-- test/i18n/load_path_test.rb | 2 +- test/i18n_test.rb | 2 +- test/locale/fallbacks_test.rb | 4 +-- test/locale/tag/rfc4646_test.rb | 6 ++--- test/locale/tag/simple_test.rb | 2 +- test/test_helper.rb | 27 ++++++++++++++------- 32 files changed, 61 insertions(+), 57 deletions(-) diff --git a/test/api/all_features_test.rb b/test/api/all_features_test.rb index 74589b7f..a1799bd6 100644 --- a/test/api/all_features_test.rb +++ b/test/api/all_features_test.rb @@ -7,7 +7,7 @@ puts "not testing with Cache enabled because active_support can not be found" end -class I18nAllFeaturesApiTest < Test::Unit::TestCase +class I18nAllFeaturesApiTest < I18n::TestCase class Backend < I18n::Backend::Simple include I18n::Backend::Metadata include I18n::Backend::Cache diff --git a/test/api/cascade_test.rb b/test/api/cascade_test.rb index a40587b3..4d9516c4 100644 --- a/test/api/cascade_test.rb +++ b/test/api/cascade_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class I18nCascadeApiTest < Test::Unit::TestCase +class I18nCascadeApiTest < I18n::TestCase class Backend < I18n::Backend::Simple include I18n::Backend::Cascade end diff --git a/test/api/chain_test.rb b/test/api/chain_test.rb index 0a61cb0a..f3dff1b5 100644 --- a/test/api/chain_test.rb +++ b/test/api/chain_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class I18nApiChainTest < Test::Unit::TestCase +class I18nApiChainTest < I18n::TestCase def setup super I18n.backend = I18n::Backend::Chain.new(I18n::Backend::Simple.new, I18n.backend) diff --git a/test/api/fallbacks_test.rb b/test/api/fallbacks_test.rb index 31ebb003..e5ca5f20 100644 --- a/test/api/fallbacks_test.rb +++ b/test/api/fallbacks_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class I18nFallbacksApiTest < Test::Unit::TestCase +class I18nFallbacksApiTest < I18n::TestCase class Backend < I18n::Backend::Simple include I18n::Backend::Fallbacks end diff --git a/test/api/key_value_test.rb b/test/api/key_value_test.rb index 976ca6ba..6a8d405f 100644 --- a/test/api/key_value_test.rb +++ b/test/api/key_value_test.rb @@ -1,8 +1,8 @@ require 'test_helper' -I18n::Tests.setup_rufus_tokyo +I18n::TestCase.setup_rufus_tokyo -class I18nKeyValueApiTest < Test::Unit::TestCase +class I18nKeyValueApiTest < I18n::TestCase include I18n::Tests::Basics include I18n::Tests::Defaults include I18n::Tests::Interpolation diff --git a/test/api/memoize_test.rb b/test/api/memoize_test.rb index 8839ec8c..0304580a 100644 --- a/test/api/memoize_test.rb +++ b/test/api/memoize_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class I18nMemoizeBackendWithSimpleApiTest < Test::Unit::TestCase +class I18nMemoizeBackendWithSimpleApiTest < I18n::TestCase include I18n::Tests::Basics include I18n::Tests::Defaults include I18n::Tests::Interpolation @@ -27,9 +27,9 @@ def setup end end -I18n::Tests.setup_rufus_tokyo +I18n::TestCase.setup_rufus_tokyo -class I18nMemoizeBackendWithKeyValueApiTest < Test::Unit::TestCase +class I18nMemoizeBackendWithKeyValueApiTest < I18n::TestCase include I18n::Tests::Basics include I18n::Tests::Defaults include I18n::Tests::Interpolation diff --git a/test/api/override_test.rb b/test/api/override_test.rb index 1f4e564e..67e1f068 100644 --- a/test/api/override_test.rb +++ b/test/api/override_test.rb @@ -1,22 +1,18 @@ require 'test_helper' -class I18nOverrideTest < Test::Unit::TestCase +class I18nOverrideTest < I18n::TestCase module OverrideInverse - def translate(*args) super(*args).reverse end alias :t :translate - end module OverrideSignature - def translate(*args) args.first + args[1] end alias :t :translate - end def setup @@ -44,5 +40,4 @@ def setup @I18n.extend OverrideSignature assert_equal 'HelloWelcome message on home page', @I18n.translate('Hello', 'Welcome message on home page', :tokenize => true) # tr8n example end - end diff --git a/test/api/pluralization_test.rb b/test/api/pluralization_test.rb index 5da3a5ef..53004beb 100644 --- a/test/api/pluralization_test.rb +++ b/test/api/pluralization_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class I18nPluralizationApiTest < Test::Unit::TestCase +class I18nPluralizationApiTest < I18n::TestCase class Backend < I18n::Backend::Simple include I18n::Backend::Pluralization end diff --git a/test/api/simple_test.rb b/test/api/simple_test.rb index 02d62058..3fd3a424 100644 --- a/test/api/simple_test.rb +++ b/test/api/simple_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class I18nSimpleBackendApiTest < Test::Unit::TestCase +class I18nSimpleBackendApiTest < I18n::TestCase class Backend < I18n::Backend::Simple include I18n::Backend::Pluralization end diff --git a/test/backend/cache_test.rb b/test/backend/cache_test.rb index 39df10d4..0f0e0285 100644 --- a/test/backend/cache_test.rb +++ b/test/backend/cache_test.rb @@ -6,7 +6,7 @@ $stderr.puts "Skipping cache tests using ActiveSupport" else -class I18nBackendCacheTest < Test::Unit::TestCase +class I18nBackendCacheTest < I18n::TestCase class Backend < I18n::Backend::Simple include I18n::Backend::Cache end diff --git a/test/backend/cascade_test.rb b/test/backend/cascade_test.rb index c23f1674..e0bda10b 100644 --- a/test/backend/cascade_test.rb +++ b/test/backend/cascade_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class I18nBackendCascadeTest < Test::Unit::TestCase +class I18nBackendCascadeTest < I18n::TestCase class Backend < I18n::Backend::Simple include I18n::Backend::Cascade end diff --git a/test/backend/chain_test.rb b/test/backend/chain_test.rb index a3bb44b4..6b554137 100644 --- a/test/backend/chain_test.rb +++ b/test/backend/chain_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class I18nBackendChainTest < Test::Unit::TestCase +class I18nBackendChainTest < I18n::TestCase def setup @first = backend(:en => { :foo => 'Foo', :formats => { :short => 'short' }, :plural_1 => { :one => '%{count}' }, :dates => {:a => "A"} diff --git a/test/backend/exceptions_test.rb b/test/backend/exceptions_test.rb index fc0f557c..5b5aef93 100644 --- a/test/backend/exceptions_test.rb +++ b/test/backend/exceptions_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class I18nBackendExceptionsTest < Test::Unit::TestCase +class I18nBackendExceptionsTest < I18n::TestCase def setup I18n.backend = I18n::Backend::Simple.new end diff --git a/test/backend/fallbacks_test.rb b/test/backend/fallbacks_test.rb index 6ea09207..82f45af9 100644 --- a/test/backend/fallbacks_test.rb +++ b/test/backend/fallbacks_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class I18nBackendFallbacksTranslateTest < Test::Unit::TestCase +class I18nBackendFallbacksTranslateTest < I18n::TestCase class Backend < I18n::Backend::Simple include I18n::Backend::Fallbacks end @@ -75,7 +75,7 @@ def setup test "should ensure that default is not splitted on new line char" do assert_equal "Default \n Bar", I18n.t(:missing_bar, :default => "Default \n Bar") end - + test "should not raise error when enforce_available_locales is true, :'pt' is missing and default is a Symbol" do I18n.enforce_available_locales = true begin @@ -86,7 +86,7 @@ def setup end end -class I18nBackendFallbacksLocalizeTest < Test::Unit::TestCase +class I18nBackendFallbacksLocalizeTest < I18n::TestCase class Backend < I18n::Backend::Simple include I18n::Backend::Fallbacks end @@ -118,7 +118,7 @@ def setup end end -class I18nBackendFallbacksWithChainTest < Test::Unit::TestCase +class I18nBackendFallbacksWithChainTest < I18n::TestCase class Backend < I18n::Backend::Simple include I18n::Backend::Fallbacks end diff --git a/test/backend/interpolation_compiler_test.rb b/test/backend/interpolation_compiler_test.rb index 50170b2e..cffe28f9 100644 --- a/test/backend/interpolation_compiler_test.rb +++ b/test/backend/interpolation_compiler_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class InterpolationCompilerTest < Test::Unit::TestCase +class InterpolationCompilerTest < I18n::TestCase Compiler = I18n::Backend::InterpolationCompiler::Compiler def compile_and_interpolate(str, values = {}) @@ -95,7 +95,7 @@ def test_custom_missing_interpolation_argument_handler end end -class I18nBackendInterpolationCompilerTest < Test::Unit::TestCase +class I18nBackendInterpolationCompilerTest < I18n::TestCase class Backend < I18n::Backend::Simple include I18n::Backend::InterpolationCompiler end diff --git a/test/backend/key_value_test.rb b/test/backend/key_value_test.rb index 74c6b7d1..b7fe8767 100644 --- a/test/backend/key_value_test.rb +++ b/test/backend/key_value_test.rb @@ -1,8 +1,8 @@ require 'test_helper' -I18n::Tests.setup_rufus_tokyo +I18n::TestCase.setup_rufus_tokyo -class I18nBackendKeyValueTest < Test::Unit::TestCase +class I18nBackendKeyValueTest < I18n::TestCase def setup_backend!(subtree=true) I18n.backend = I18n::Backend::KeyValue.new(Rufus::Tokyo::Cabinet.new('*'), subtree) store_translations(:en, :foo => { :bar => 'bar', :baz => 'baz' }) diff --git a/test/backend/metadata_test.rb b/test/backend/metadata_test.rb index 584c7f65..5ccb6462 100644 --- a/test/backend/metadata_test.rb +++ b/test/backend/metadata_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class I18nBackendMetadataTest < Test::Unit::TestCase +class I18nBackendMetadataTest < I18n::TestCase class Backend < I18n::Backend::Simple include I18n::Backend::Metadata end diff --git a/test/backend/pluralization_test.rb b/test/backend/pluralization_test.rb index 54fbba92..de318f1a 100644 --- a/test/backend/pluralization_test.rb +++ b/test/backend/pluralization_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class I18nBackendPluralizationTest < Test::Unit::TestCase +class I18nBackendPluralizationTest < I18n::TestCase class Backend < I18n::Backend::Simple include I18n::Backend::Pluralization include I18n::Backend::Fallbacks diff --git a/test/backend/simple_test.rb b/test/backend/simple_test.rb index 4f37f48e..777a77c7 100644 --- a/test/backend/simple_test.rb +++ b/test/backend/simple_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class I18nBackendSimpleTest < Test::Unit::TestCase +class I18nBackendSimpleTest < I18n::TestCase def setup I18n.backend = I18n::Backend::Simple.new I18n.load_path = [locales_dir + '/en.yml'] diff --git a/test/backend/transliterator_test.rb b/test/backend/transliterator_test.rb index a7f914e0..4012dce2 100644 --- a/test/backend/transliterator_test.rb +++ b/test/backend/transliterator_test.rb @@ -1,7 +1,7 @@ # encoding: utf-8 require 'test_helper' -class I18nBackendTransliterator < Test::Unit::TestCase +class I18nBackendTransliterator < I18n::TestCase def setup I18n.backend = I18n::Backend::Simple.new @proc = lambda { |n| n.upcase } diff --git a/test/core_ext/hash_test.rb b/test/core_ext/hash_test.rb index 25c57488..83093365 100644 --- a/test/core_ext/hash_test.rb +++ b/test/core_ext/hash_test.rb @@ -1,7 +1,7 @@ require 'test_helper' require 'i18n/core_ext/hash' -class I18nCoreExtHashInterpolationTest < Test::Unit::TestCase +class I18nCoreExtHashInterpolationTest < I18n::TestCase test "#deep_symbolize_keys" do hash = { 'foo' => { 'bar' => { 'baz' => 'bar' } } } expected = { :foo => { :bar => { :baz => 'bar' } } } diff --git a/test/core_ext/string/interpolate_test.rb b/test/core_ext/string/interpolate_test.rb index 993d454d..a1ed9c4c 100644 --- a/test/core_ext/string/interpolate_test.rb +++ b/test/core_ext/string/interpolate_test.rb @@ -5,7 +5,7 @@ # some tests taken from Masao's tests # http://github.com/mutoh/gettext/blob/edbbe1fa8238fa12c7f26f2418403015f0270e47/test/test_string.rb -class I18nCoreExtStringInterpolationTest < Test::Unit::TestCase +class I18nCoreExtStringInterpolationTest < I18n::TestCase test "String interpolates a single argument" do assert_equal "Masao", "%s" % "Masao" end diff --git a/test/gettext/api_test.rb b/test/gettext/api_test.rb index 947b5a23..ac4edaf0 100644 --- a/test/gettext/api_test.rb +++ b/test/gettext/api_test.rb @@ -4,7 +4,7 @@ include I18n::Gettext::Helpers -class I18nGettextApiTest < Test::Unit::TestCase +class I18nGettextApiTest < I18n::TestCase def setup I18n.locale = :en I18n.backend.store_translations :de, { diff --git a/test/gettext/backend_test.rb b/test/gettext/backend_test.rb index 39c64b35..ebba90b5 100644 --- a/test/gettext/backend_test.rb +++ b/test/gettext/backend_test.rb @@ -5,7 +5,7 @@ # apparently Ruby 1.9.1p129 has encoding problems with the gettext po parser unless RUBY_VERSION == '1.9.1' && RUBY_PATCHLEVEL <= 129 - class I18nGettextBackendTest < Test::Unit::TestCase + class I18nGettextBackendTest < I18n::TestCase include I18n::Gettext::Helpers class Backend < I18n::Backend::Simple diff --git a/test/i18n/exceptions_test.rb b/test/i18n/exceptions_test.rb index 2e5e1898..e633d7d9 100644 --- a/test/i18n/exceptions_test.rb +++ b/test/i18n/exceptions_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class I18nExceptionsTest < Test::Unit::TestCase +class I18nExceptionsTest < I18n::TestCase def test_invalid_locale_stores_locale force_invalid_locale rescue I18n::ArgumentError => exception diff --git a/test/i18n/interpolate_test.rb b/test/i18n/interpolate_test.rb index 7041b322..74b6204d 100644 --- a/test/i18n/interpolate_test.rb +++ b/test/i18n/interpolate_test.rb @@ -4,7 +4,7 @@ # thanks to Masao's String extensions, some tests taken from Masao's tests # http://github.com/mutoh/gettext/blob/edbbe1fa8238fa12c7f26f2418403015f0270e47/test/test_string.rb -class I18nInterpolateTest < Test::Unit::TestCase +class I18nInterpolateTest < I18n::TestCase test "String interpolates a hash argument w/ named placeholders" do assert_equal "Masao Mutoh", I18n.interpolate("%{first} %{last}", :first => 'Masao', :last => 'Mutoh' ) end @@ -60,7 +60,7 @@ def test_sprintf_mix_unformatted_and_formatted_named_placeholders end end -class I18nMissingInterpolationCustomHandlerTest < Test::Unit::TestCase +class I18nMissingInterpolationCustomHandlerTest < I18n::TestCase def setup @old_handler = I18n.config.missing_interpolation_argument_handler I18n.config.missing_interpolation_argument_handler = lambda do |key, values, string| diff --git a/test/i18n/load_path_test.rb b/test/i18n/load_path_test.rb index 26d086ab..ebb023e7 100644 --- a/test/i18n/load_path_test.rb +++ b/test/i18n/load_path_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class I18nLoadPathTest < Test::Unit::TestCase +class I18nLoadPathTest < I18n::TestCase def setup I18n.locale = :en I18n.backend = I18n::Backend::Simple.new diff --git a/test/i18n_test.rb b/test/i18n_test.rb index fd7e5ea8..c64d595c 100644 --- a/test/i18n_test.rb +++ b/test/i18n_test.rb @@ -1,7 +1,7 @@ # encoding: utf-8 require 'test_helper' -class I18nTest < Test::Unit::TestCase +class I18nTest < I18n::TestCase def setup store_translations(:en, :currency => { :format => { :separator => '.', :delimiter => ',', } }) store_translations(:nl, :currency => { :format => { :separator => ',', :delimiter => '.', } }) diff --git a/test/locale/fallbacks_test.rb b/test/locale/fallbacks_test.rb index ca5e9427..b25f02d2 100644 --- a/test/locale/fallbacks_test.rb +++ b/test/locale/fallbacks_test.rb @@ -2,7 +2,7 @@ include I18n::Locale -class I18nFallbacksDefaultsTest < Test::Unit::TestCase +class I18nFallbacksDefaultsTest < I18n::TestCase def teardown I18n.default_locale = :en end @@ -26,7 +26,7 @@ def teardown end end -class I18nFallbacksComputationTest < Test::Unit::TestCase +class I18nFallbacksComputationTest < I18n::TestCase def setup @fallbacks = Fallbacks.new(:'en-US') end diff --git a/test/locale/tag/rfc4646_test.rb b/test/locale/tag/rfc4646_test.rb index 11180493..97fa6e45 100644 --- a/test/locale/tag/rfc4646_test.rb +++ b/test/locale/tag/rfc4646_test.rb @@ -1,7 +1,7 @@ # encoding: utf-8 require 'test_helper' -class I18nLocaleTagRfc4646ParserTest < Test::Unit::TestCase +class I18nLocaleTagRfc4646ParserTest < I18n::TestCase include I18n::Locale test "Rfc4646::Parser given a valid tag 'de' returns an array of subtags" do @@ -31,7 +31,7 @@ class I18nLocaleTagRfc4646ParserTest < Test::Unit::TestCase # Tag for the locale 'de-Latn-DE-Variant-a-ext-x-phonebk-i-klingon' -class I18nLocaleTagSubtagsTest < Test::Unit::TestCase +class I18nLocaleTagSubtagsTest < I18n::TestCase include I18n::Locale def setup @@ -78,7 +78,7 @@ def setup # Tag inheritance -class I18nLocaleTagSubtagsTest < Test::Unit::TestCase +class I18nLocaleTagSubtagsTest < I18n::TestCase 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 tag = Tag::Rfc4646.new(*%w(de Latn DE variant a-ext x-phonebk i-klingon)) assert_equal 'de-Latn-DE-variant-a-ext-x-phonebk', tag.parent.to_s diff --git a/test/locale/tag/simple_test.rb b/test/locale/tag/simple_test.rb index ed2f76b4..002c63d2 100644 --- a/test/locale/tag/simple_test.rb +++ b/test/locale/tag/simple_test.rb @@ -1,7 +1,7 @@ # encoding: utf-8 require 'test_helper' -class I18nLocaleTagSimpleTest < Test::Unit::TestCase +class I18nLocaleTagSimpleTest < I18n::TestCase include I18n::Locale test "returns 'de' as the language subtag in lowercase" do diff --git a/test/test_helper.rb b/test/test_helper.rb index e23b5abb..53f34aad 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -17,8 +17,15 @@ def gem(gem_name, *version_requirements) require 'mocha/setup' require 'test_declarative' -class Test::Unit::TestCase +class I18n::TestCase < Test::Unit::TestCase + def self.setup_rufus_tokyo + require 'rufus/tokyo' + rescue LoadError => e + puts "can't use KeyValue backend because: #{e.message}" + end + def teardown + super I18n.locale = nil I18n.default_locale = :en I18n.load_path = [] @@ -27,6 +34,16 @@ def teardown I18n.enforce_available_locales = nil end + # Ignore Test::Unit::TestCase failing if the test case does not contain any + # test, otherwise it will blow up because of this base class. + # + # TODO: remove when test-unit is not used anymore. + def default_test + nil + end + + protected + def translations I18n.backend.instance_variable_get(:@translations) end @@ -39,11 +56,3 @@ def locales_dir File.dirname(__FILE__) + '/test_data/locales' end end - -module I18n::Tests - def self.setup_rufus_tokyo - require 'rufus/tokyo' - rescue LoadError => e - puts "can't use KeyValue backend because: #{e.message}" - end -end From 82562260aed23c80a4bfe3dd668afbc9fb79bd61 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Wed, 28 May 2014 12:42:57 -0300 Subject: [PATCH 047/145] Test against latest Ruby 2.1 available in travis --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 075fc585..0fd98352 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ rvm: - 1.8.7 - 1.9.3 - 2.0.0 - - 2.1.1 + - 2.1 - ree - rbx - jruby @@ -27,7 +27,7 @@ matrix: - gemfile: gemfiles/Gemfile.rails-2.3.x rvm: 2.0.0 - gemfile: gemfiles/Gemfile.rails-2.3.x - rvm: 2.1.1 + rvm: 2.1 - gemfile: gemfiles/Gemfile.rails-2.3.x rvm: rbx - gemfile: gemfiles/Gemfile.rails-2.3.x From 080a79a4cc0715e06a0a0cd10a0b19746bbd97de Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Wed, 28 May 2014 12:46:23 -0300 Subject: [PATCH 048/145] Update travis badge and link to the project on travis [ci skip] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9f638eea..aeba4c02 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Ruby I18n -![Build Status](https://secure.travis-ci.org/svenfuchs/i18n.png?branch=master) +[![Build Status](https://api.travis-ci.org/svenfuchs/i18n.png?branch=master)](https://travis-ci.org/svenfuchs/i18n) Ruby Internationalization and localization solution. From 54dae133d17a32e764bf5dad8674eea1ea81859b Mon Sep 17 00:00:00 2001 From: Arthur Nogueira Neves Date: Wed, 28 May 2014 11:49:53 -0400 Subject: [PATCH 049/145] Use svg travis badge [skip ci] @carlosantoniodasilva as you are in here already.. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index aeba4c02..df796956 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Ruby I18n -[![Build Status](https://api.travis-ci.org/svenfuchs/i18n.png?branch=master)](https://travis-ci.org/svenfuchs/i18n) +[![Build Status](https://api.travis-ci.org/svenfuchs/i18n.svg?branch=master)](https://travis-ci.org/svenfuchs/i18n) Ruby Internationalization and localization solution. From c6d95dafa30253c992047e699b26377669979af0 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Fri, 9 May 2014 10:48:45 -0300 Subject: [PATCH 050/145] Fix Gemfile dependencies for Rails 4.1 and use Minitest if available Fallback to test/unit in case minitest is not available, which should be necessary for Ruby 1.8.7 only. --- gemfiles/Gemfile.rails-4.1.x | 2 +- gemfiles/Gemfile.rails-4.1.x.lock | 17 +++++++++-------- test/test_helper.rb | 22 ++++++++++++++++++++-- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/gemfiles/Gemfile.rails-4.1.x b/gemfiles/Gemfile.rails-4.1.x index ac0793d0..8db40a50 100644 --- a/gemfiles/Gemfile.rails-4.1.x +++ b/gemfiles/Gemfile.rails-4.1.x @@ -2,7 +2,7 @@ source 'https://rubygems.org' gemspec :path => '..' -gem 'activesupport', '~> 4.0.0' +gem 'activesupport', '~> 4.1.0' gem 'mocha' gem 'test_declarative' gem 'rufus-tokyo' diff --git a/gemfiles/Gemfile.rails-4.1.x.lock b/gemfiles/Gemfile.rails-4.1.x.lock index 09eefb62..ddf8a1d8 100644 --- a/gemfiles/Gemfile.rails-4.1.x.lock +++ b/gemfiles/Gemfile.rails-4.1.x.lock @@ -6,29 +6,30 @@ PATH GEM remote: https://rubygems.org/ specs: - activesupport (4.0.5) + activesupport (4.1.1) i18n (~> 0.6, >= 0.6.9) - minitest (~> 4.2) - multi_json (~> 1.3) + json (~> 1.7, >= 1.7.7) + minitest (~> 5.1) thread_safe (~> 0.1) - tzinfo (~> 0.3.37) + tzinfo (~> 1.1) ffi (1.9.3) + json (1.8.1) metaclass (0.0.4) - minitest (4.7.5) + minitest (5.3.3) mocha (1.0.0) metaclass (~> 0.0.1) - multi_json (1.10.0) rake (10.3.1) rufus-tokyo (1.0.7) test_declarative (0.0.5) thread_safe (0.3.3) - tzinfo (0.3.39) + tzinfo (1.1.0) + thread_safe (~> 0.1) PLATFORMS ruby DEPENDENCIES - activesupport (~> 4.0.0) + activesupport (~> 4.1.0) ffi i18n! mocha diff --git a/test/test_helper.rb b/test/test_helper.rb index 53f34aad..d24b81f3 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,7 +1,25 @@ $KCODE = 'u' if RUBY_VERSION <= '1.9' require 'rubygems' -require 'test/unit' + +# Use minitest if we can, otherwise fallback to test-unit. +begin + require 'minitest/autorun' + TEST_CASE = defined?(Minitest::Test) ? Minitest::Test : MiniTest::Unit::TestCase + + # TODO: Remove these aliases and update tests accordingly. + class TEST_CASE + alias :assert_raise :assert_raises + alias :assert_not_equal :refute_equal + + def assert_nothing_raised(*args) + yield + end + end +rescue LoadError + require 'test/unit' + TEST_CASE = Test::Unit::TestCase +end # Do not load the i18n gem from libraries like active_support. # @@ -17,7 +35,7 @@ def gem(gem_name, *version_requirements) require 'mocha/setup' require 'test_declarative' -class I18n::TestCase < Test::Unit::TestCase +class I18n::TestCase < TEST_CASE def self.setup_rufus_tokyo require 'rufus/tokyo' rescue LoadError => e From 47f9a966a3c93ea388835d1a34a8bf87f539641c Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Wed, 28 May 2014 19:24:44 -0300 Subject: [PATCH 051/145] Add bundler gem tasks for building/releasing --- Rakefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Rakefile b/Rakefile index ab8cc969..5e6e1dbf 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,4 @@ +require 'bundler/gem_tasks' require 'rake/testtask' task :default => [:test] From 667bcfe176da52fbff73c41d3591f3db8242e698 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Wed, 28 May 2014 19:29:04 -0300 Subject: [PATCH 052/145] Bump to 0.6.10 --- Gemfile.lock | 2 +- gemfiles/Gemfile.rails-2.3.x.lock | 2 +- gemfiles/Gemfile.rails-3.0.x.lock | 2 +- gemfiles/Gemfile.rails-3.1.x.lock | 2 +- gemfiles/Gemfile.rails-3.2.x.lock | 2 +- gemfiles/Gemfile.rails-4.0.x.lock | 2 +- gemfiles/Gemfile.rails-4.1.x.lock | 2 +- lib/i18n/version.rb | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index eef0e235..42eabc0f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - i18n (0.6.9) + i18n (0.6.10) GEM remote: https://rubygems.org/ diff --git a/gemfiles/Gemfile.rails-2.3.x.lock b/gemfiles/Gemfile.rails-2.3.x.lock index d56b2e10..453fb741 100644 --- a/gemfiles/Gemfile.rails-2.3.x.lock +++ b/gemfiles/Gemfile.rails-2.3.x.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - i18n (0.6.9) + i18n (0.6.10) GEM remote: https://rubygems.org/ diff --git a/gemfiles/Gemfile.rails-3.0.x.lock b/gemfiles/Gemfile.rails-3.0.x.lock index 49f4a9ea..12d85243 100644 --- a/gemfiles/Gemfile.rails-3.0.x.lock +++ b/gemfiles/Gemfile.rails-3.0.x.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - i18n (0.6.9) + i18n (0.6.10) GEM remote: https://rubygems.org/ diff --git a/gemfiles/Gemfile.rails-3.1.x.lock b/gemfiles/Gemfile.rails-3.1.x.lock index cd380db1..d3f0789e 100644 --- a/gemfiles/Gemfile.rails-3.1.x.lock +++ b/gemfiles/Gemfile.rails-3.1.x.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - i18n (0.6.9) + i18n (0.6.10) GEM remote: https://rubygems.org/ diff --git a/gemfiles/Gemfile.rails-3.2.x.lock b/gemfiles/Gemfile.rails-3.2.x.lock index 9425642d..a036794a 100644 --- a/gemfiles/Gemfile.rails-3.2.x.lock +++ b/gemfiles/Gemfile.rails-3.2.x.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - i18n (0.6.9) + i18n (0.6.10) GEM remote: https://rubygems.org/ diff --git a/gemfiles/Gemfile.rails-4.0.x.lock b/gemfiles/Gemfile.rails-4.0.x.lock index 09eefb62..e2dd7011 100644 --- a/gemfiles/Gemfile.rails-4.0.x.lock +++ b/gemfiles/Gemfile.rails-4.0.x.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - i18n (0.6.9) + i18n (0.6.10) GEM remote: https://rubygems.org/ diff --git a/gemfiles/Gemfile.rails-4.1.x.lock b/gemfiles/Gemfile.rails-4.1.x.lock index ddf8a1d8..945f3d7f 100644 --- a/gemfiles/Gemfile.rails-4.1.x.lock +++ b/gemfiles/Gemfile.rails-4.1.x.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - i18n (0.6.9) + i18n (0.6.10) GEM remote: https://rubygems.org/ diff --git a/lib/i18n/version.rb b/lib/i18n/version.rb index 01f274a3..87cda09f 100644 --- a/lib/i18n/version.rb +++ b/lib/i18n/version.rb @@ -1,3 +1,3 @@ module I18n - VERSION = "0.6.9" + VERSION = "0.6.10" end From f4d1d8f3eb672f442988d925daba81b0a525d7c1 Mon Sep 17 00:00:00 2001 From: Arthur Neves Date: Thu, 29 May 2014 00:07:04 -0400 Subject: [PATCH 053/145] Fix error when including Fallbacks on non-Simple backend Commit 12aa0f0d0fc1822d6825d81bb9cdfdc4eb325dfd introduced a bug, where if `Fallbacks` module is included in a class that doesnt define `translations` the code would fail. This is a pretty common scenario, for instance when the backend is a `Chain`. Also this was pretty common case to fail in rails, as its include Fallbacks in the I18n.backend, like this: ``` I18n.backend.class.send(:include, I18n::Backend::Fallbacks) ``` This stops using the `translations` method in the fallbacks, and instead ignores `I18n::InvalidLocale` errors. [fixes #238] [fixes #258] [fixes #259] --- lib/i18n/backend/fallbacks.rb | 11 +++++++---- test/backend/fallbacks_test.rb | 11 +++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/i18n/backend/fallbacks.rb b/lib/i18n/backend/fallbacks.rb index e55e0226..d74b800c 100644 --- a/lib/i18n/backend/fallbacks.rb +++ b/lib/i18n/backend/fallbacks.rb @@ -40,10 +40,13 @@ def translate(locale, key, options = {}) options[:fallback] = true I18n.fallbacks[locale].each do |fallback| - next unless translations.keys.include?(fallback) - catch(:exception) do - result = super(fallback, key, options) - return result unless result.nil? + begin + catch(:exception) do + result = super(fallback, key, options) + return result unless result.nil? + end + rescue I18n::InvalidLocale + # we do nothing when the locale is invalid, as this is a fallback anyways. end end options.delete(:fallback) diff --git a/test/backend/fallbacks_test.rb b/test/backend/fallbacks_test.rb index 82f45af9..8baeed6c 100644 --- a/test/backend/fallbacks_test.rb +++ b/test/backend/fallbacks_test.rb @@ -126,10 +126,21 @@ class Backend < I18n::Backend::Simple def setup backend = Backend.new backend.store_translations(:de, :foo => 'FOO') + backend.store_translations(:'pt-BR', :foo => 'Baz in :pt-BR') I18n.backend = I18n::Backend::Chain.new(I18n::Backend::Simple.new, backend) + I18n.backend.class.send(:include, I18n::Backend::Fallbacks) end test "falls back from de-DE to de when there is no translation for de-DE available" do assert_equal 'FOO', I18n.t(:foo, :locale => :'de-DE') end + + test "should not raise error when enforce_available_locales is true, :'pt' is missing and default is a Symbol" do + I18n.enforce_available_locales = true + begin + assert_equal 'Foo', I18n.t(:'model.attrs.foo', :locale => :'pt-BR', :default => [:'attrs.foo', "Foo"]) + ensure + I18n.enforce_available_locales = false + end + end end From 3d9e547bf70ed2a83c873d6823e45a91b22c1001 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Sun, 29 Jun 2014 12:28:42 -0700 Subject: [PATCH 054/145] add minitest to Gemfile --- Gemfile | 1 + Gemfile.lock | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Gemfile b/Gemfile index 24ca9f45..92f28620 100644 --- a/Gemfile +++ b/Gemfile @@ -5,3 +5,4 @@ gemspec gem 'mocha' gem 'test_declarative' gem 'rake' +gem 'minitest' diff --git a/Gemfile.lock b/Gemfile.lock index 42eabc0f..4c10ea34 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,6 +7,7 @@ GEM remote: https://rubygems.org/ specs: metaclass (0.0.4) + minitest (5.3.5) mocha (1.0.0) metaclass (~> 0.0.1) rake (10.3.1) @@ -18,6 +19,7 @@ PLATFORMS DEPENDENCIES i18n! + minitest mocha rake test_declarative From fb6c782b5e450cc15cf333eb98519a35a9d055bb Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Sun, 29 Jun 2014 14:24:37 -0700 Subject: [PATCH 055/145] add test pattern to the Rakefile so all tests are run --- Rakefile | 3 ++- test/all.rb | 8 -------- 2 files changed, 2 insertions(+), 9 deletions(-) delete mode 100644 test/all.rb diff --git a/Rakefile b/Rakefile index 5e6e1dbf..65eb0ef1 100644 --- a/Rakefile +++ b/Rakefile @@ -6,7 +6,8 @@ task :default => [:test] Rake::TestTask.new(:test) do |t| t.libs << 'lib' t.libs << 'test' - t.pattern = "#{File.dirname(__FILE__)}/test/all.rb" + dir = File.dirname(__FILE__) + t.pattern = "#{dir}/**/*_test.rb" t.verbose = true t.warning = true end diff --git a/test/all.rb b/test/all.rb deleted file mode 100644 index e846143a..00000000 --- a/test/all.rb +++ /dev/null @@ -1,8 +0,0 @@ -# encoding: utf-8 - -dir = File.dirname(__FILE__) -$LOAD_PATH.unshift(dir) - -Dir["#{dir}/**/*_test.rb"].sort.each do |file| - require file.sub(/^#{dir}\/(.*)\.rb$/, '\1') -end From 45693e8abe67f2d7a389b0aadffef7428014b282 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Sun, 29 Jun 2014 16:21:59 -0700 Subject: [PATCH 056/145] fix test failure with seed 24594 --- test/backend/fallbacks_test.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/backend/fallbacks_test.rb b/test/backend/fallbacks_test.rb index 8baeed6c..6491585a 100644 --- a/test/backend/fallbacks_test.rb +++ b/test/backend/fallbacks_test.rb @@ -124,11 +124,17 @@ class Backend < I18n::Backend::Simple end def setup + @old_backend = I18n.backend backend = Backend.new backend.store_translations(:de, :foo => 'FOO') backend.store_translations(:'pt-BR', :foo => 'Baz in :pt-BR') - I18n.backend = I18n::Backend::Chain.new(I18n::Backend::Simple.new, backend) - I18n.backend.class.send(:include, I18n::Backend::Fallbacks) + klass = Class.new(I18n::Backend::Chain) + klass.send :include, I18n::Backend::Fallbacks + I18n.backend = klass.new(I18n::Backend::Simple.new, backend) + end + + def teardown + I18n.backend = @old_backend end test "falls back from de-DE to de when there is no translation for de-DE available" do From 9eadb6bb71cf13554514d2d6f22a0884891ebee0 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Wed, 9 Jul 2014 14:57:34 -0300 Subject: [PATCH 057/145] Bump to 0.6.11 --- Gemfile.lock | 2 +- gemfiles/Gemfile.rails-2.3.x.lock | 2 +- gemfiles/Gemfile.rails-3.0.x.lock | 2 +- gemfiles/Gemfile.rails-3.1.x.lock | 2 +- gemfiles/Gemfile.rails-3.2.x.lock | 2 +- gemfiles/Gemfile.rails-4.0.x.lock | 2 +- gemfiles/Gemfile.rails-4.1.x.lock | 2 +- lib/i18n/version.rb | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 42eabc0f..9ac6350a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - i18n (0.6.10) + i18n (0.6.11) GEM remote: https://rubygems.org/ diff --git a/gemfiles/Gemfile.rails-2.3.x.lock b/gemfiles/Gemfile.rails-2.3.x.lock index 453fb741..136d146f 100644 --- a/gemfiles/Gemfile.rails-2.3.x.lock +++ b/gemfiles/Gemfile.rails-2.3.x.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - i18n (0.6.10) + i18n (0.6.11) GEM remote: https://rubygems.org/ diff --git a/gemfiles/Gemfile.rails-3.0.x.lock b/gemfiles/Gemfile.rails-3.0.x.lock index 12d85243..d0e85b9a 100644 --- a/gemfiles/Gemfile.rails-3.0.x.lock +++ b/gemfiles/Gemfile.rails-3.0.x.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - i18n (0.6.10) + i18n (0.6.11) GEM remote: https://rubygems.org/ diff --git a/gemfiles/Gemfile.rails-3.1.x.lock b/gemfiles/Gemfile.rails-3.1.x.lock index d3f0789e..9b165588 100644 --- a/gemfiles/Gemfile.rails-3.1.x.lock +++ b/gemfiles/Gemfile.rails-3.1.x.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - i18n (0.6.10) + i18n (0.6.11) GEM remote: https://rubygems.org/ diff --git a/gemfiles/Gemfile.rails-3.2.x.lock b/gemfiles/Gemfile.rails-3.2.x.lock index a036794a..647bd1ed 100644 --- a/gemfiles/Gemfile.rails-3.2.x.lock +++ b/gemfiles/Gemfile.rails-3.2.x.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - i18n (0.6.10) + i18n (0.6.11) GEM remote: https://rubygems.org/ diff --git a/gemfiles/Gemfile.rails-4.0.x.lock b/gemfiles/Gemfile.rails-4.0.x.lock index e2dd7011..1b35c2fc 100644 --- a/gemfiles/Gemfile.rails-4.0.x.lock +++ b/gemfiles/Gemfile.rails-4.0.x.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - i18n (0.6.10) + i18n (0.6.11) GEM remote: https://rubygems.org/ diff --git a/gemfiles/Gemfile.rails-4.1.x.lock b/gemfiles/Gemfile.rails-4.1.x.lock index 945f3d7f..9807d90d 100644 --- a/gemfiles/Gemfile.rails-4.1.x.lock +++ b/gemfiles/Gemfile.rails-4.1.x.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - i18n (0.6.10) + i18n (0.6.11) GEM remote: https://rubygems.org/ diff --git a/lib/i18n/version.rb b/lib/i18n/version.rb index 87cda09f..0b68b31c 100644 --- a/lib/i18n/version.rb +++ b/lib/i18n/version.rb @@ -1,3 +1,3 @@ module I18n - VERSION = "0.6.10" + VERSION = "0.6.11" end From 5e3e6a870ed1e255f62f1b2493bb51cccc472f73 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Wed, 9 Jul 2014 15:06:46 -0300 Subject: [PATCH 058/145] Bump minitest --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index b0708bab..1eca0271 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,7 +7,7 @@ GEM remote: https://rubygems.org/ specs: metaclass (0.0.4) - minitest (5.3.5) + minitest (5.4.0) mocha (1.0.0) metaclass (~> 0.0.1) rake (10.3.1) From 8c11065392b64ee6f1fda1a90407c1a86c9c847d Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Wed, 9 Jul 2014 15:09:59 -0300 Subject: [PATCH 059/145] Fix run_all script to use rake test --- README.md | 1 - test/run_all.rb | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index df796956..da072a3d 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,6 @@ You can run tests both with * `rake test` or just `rake` * run any test file directly, e.g. `ruby -Ilib -Itest test/api/simple_test.rb` -* run all tests with `ruby -Ilib -Itest test/all.rb` You can run all tests against all Gemfiles with diff --git a/test/run_all.rb b/test/run_all.rb index 46bc43c3..64ff743d 100644 --- a/test/run_all.rb +++ b/test/run_all.rb @@ -14,7 +14,7 @@ def execute(command) ENV['BUNDLE_GEMFILE'] = File.expand_path("../../#{gemfile}", __FILE__) execute 'bundle install' unless bundle_check - execute 'bundle exec ruby -w -Ilib -Itest test/all.rb' + execute 'bundle exec rake test' end exit results.all? From 580da2e9bc64e96259ca6c19754691efa084455d Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Fri, 9 May 2014 11:56:10 -0300 Subject: [PATCH 060/145] Ensure super is called from setup/teardown methods across the test suite So that the base config/cleanup works as expected. --- test/api/override_test.rb | 2 +- test/backend/cache_test.rb | 1 + test/backend/cascade_test.rb | 1 + test/backend/chain_test.rb | 1 + test/backend/exceptions_test.rb | 1 + test/backend/fallbacks_test.rb | 3 +++ test/backend/metadata_test.rb | 1 + test/backend/pluralization_test.rb | 1 + test/backend/simple_test.rb | 1 + test/backend/transliterator_test.rb | 1 + test/gettext/api_test.rb | 1 + test/gettext/backend_test.rb | 2 ++ test/i18n/interpolate_test.rb | 2 ++ test/i18n/load_path_test.rb | 1 + test/i18n_test.rb | 1 + test/locale/fallbacks_test.rb | 2 ++ test/locale/tag/rfc4646_test.rb | 1 + test/test_helper.rb | 9 +++++++-- 18 files changed, 29 insertions(+), 3 deletions(-) diff --git a/test/api/override_test.rb b/test/api/override_test.rb index 67e1f068..e8cb29c9 100644 --- a/test/api/override_test.rb +++ b/test/api/override_test.rb @@ -16,9 +16,9 @@ def translate(*args) end def setup + super @I18n = I18n.dup @I18n.backend = I18n::Backend::Simple.new - super end test "make sure modules can overwrite I18n methods" do diff --git a/test/backend/cache_test.rb b/test/backend/cache_test.rb index 0f0e0285..8e144a15 100644 --- a/test/backend/cache_test.rb +++ b/test/backend/cache_test.rb @@ -18,6 +18,7 @@ def setup end def teardown + super I18n.cache_store = nil end diff --git a/test/backend/cascade_test.rb b/test/backend/cascade_test.rb index e0bda10b..11014605 100644 --- a/test/backend/cascade_test.rb +++ b/test/backend/cascade_test.rb @@ -6,6 +6,7 @@ class Backend < I18n::Backend::Simple end def setup + super I18n.backend = Backend.new store_translations(:en, :foo => 'foo', :bar => { :baz => 'baz' }) @cascade_options = { :step => 1, :offset => 1, :skip_root => false } diff --git a/test/backend/chain_test.rb b/test/backend/chain_test.rb index 6b554137..a0643374 100644 --- a/test/backend/chain_test.rb +++ b/test/backend/chain_test.rb @@ -2,6 +2,7 @@ class I18nBackendChainTest < I18n::TestCase def setup + super @first = backend(:en => { :foo => 'Foo', :formats => { :short => 'short' }, :plural_1 => { :one => '%{count}' }, :dates => {:a => "A"} }) diff --git a/test/backend/exceptions_test.rb b/test/backend/exceptions_test.rb index 5b5aef93..cc221669 100644 --- a/test/backend/exceptions_test.rb +++ b/test/backend/exceptions_test.rb @@ -2,6 +2,7 @@ class I18nBackendExceptionsTest < I18n::TestCase def setup + super I18n.backend = I18n::Backend::Simple.new end diff --git a/test/backend/fallbacks_test.rb b/test/backend/fallbacks_test.rb index 8baeed6c..402aaac1 100644 --- a/test/backend/fallbacks_test.rb +++ b/test/backend/fallbacks_test.rb @@ -6,6 +6,7 @@ class Backend < I18n::Backend::Simple end def setup + super I18n.backend = Backend.new store_translations(:en, :foo => 'Foo in :en', :bar => 'Bar in :en', :buz => 'Buz in :en') store_translations(:de, :bar => 'Bar in :de', :baz => 'Baz in :de') @@ -92,6 +93,7 @@ class Backend < I18n::Backend::Simple end def setup + super I18n.backend = Backend.new store_translations(:en, :date => { :formats => { :en => 'en' }, :day_names => %w(Sunday) }) store_translations(:de, :date => { :formats => { :de => 'de' } }) @@ -124,6 +126,7 @@ class Backend < I18n::Backend::Simple end def setup + super backend = Backend.new backend.store_translations(:de, :foo => 'FOO') backend.store_translations(:'pt-BR', :foo => 'Baz in :pt-BR') diff --git a/test/backend/metadata_test.rb b/test/backend/metadata_test.rb index 5ccb6462..44612cf0 100644 --- a/test/backend/metadata_test.rb +++ b/test/backend/metadata_test.rb @@ -6,6 +6,7 @@ class Backend < I18n::Backend::Simple end def setup + super I18n.backend = Backend.new store_translations(:en, :foo => 'Hi %{name}') end diff --git a/test/backend/pluralization_test.rb b/test/backend/pluralization_test.rb index de318f1a..1518efdb 100644 --- a/test/backend/pluralization_test.rb +++ b/test/backend/pluralization_test.rb @@ -7,6 +7,7 @@ class Backend < I18n::Backend::Simple end def setup + super I18n.backend = Backend.new @rule = lambda { |n| n == 1 ? :one : n == 0 || (2..10).include?(n % 100) ? :few : (11..19).include?(n % 100) ? :many : :other } store_translations(:xx, :i18n => { :plural => { :rule => @rule } }) diff --git a/test/backend/simple_test.rb b/test/backend/simple_test.rb index 777a77c7..58782b41 100644 --- a/test/backend/simple_test.rb +++ b/test/backend/simple_test.rb @@ -2,6 +2,7 @@ class I18nBackendSimpleTest < I18n::TestCase def setup + super I18n.backend = I18n::Backend::Simple.new I18n.load_path = [locales_dir + '/en.yml'] end diff --git a/test/backend/transliterator_test.rb b/test/backend/transliterator_test.rb index 4012dce2..89e99735 100644 --- a/test/backend/transliterator_test.rb +++ b/test/backend/transliterator_test.rb @@ -3,6 +3,7 @@ class I18nBackendTransliterator < I18n::TestCase def setup + super I18n.backend = I18n::Backend::Simple.new @proc = lambda { |n| n.upcase } @hash = { "ü" => "ue", "ö" => "oe", "a" => "a" } diff --git a/test/gettext/api_test.rb b/test/gettext/api_test.rb index ac4edaf0..4297400b 100644 --- a/test/gettext/api_test.rb +++ b/test/gettext/api_test.rb @@ -6,6 +6,7 @@ class I18nGettextApiTest < I18n::TestCase def setup + super I18n.locale = :en I18n.backend.store_translations :de, { 'Hi Gettext!' => 'Hallo Gettext!', diff --git a/test/gettext/backend_test.rb b/test/gettext/backend_test.rb index ebba90b5..960c1eeb 100644 --- a/test/gettext/backend_test.rb +++ b/test/gettext/backend_test.rb @@ -13,6 +13,7 @@ class Backend < I18n::Backend::Simple end def setup + super I18n.backend = Backend.new I18n.locale = :en I18n.load_path = ["#{locales_dir}/de.po"] @@ -23,6 +24,7 @@ def teardown I18n.load_path = nil I18n.backend = nil I18n.default_separator = @old_separator + super end def test_backend_loads_po_file diff --git a/test/i18n/interpolate_test.rb b/test/i18n/interpolate_test.rb index 74b6204d..cb80908f 100644 --- a/test/i18n/interpolate_test.rb +++ b/test/i18n/interpolate_test.rb @@ -62,6 +62,7 @@ def test_sprintf_mix_unformatted_and_formatted_named_placeholders class I18nMissingInterpolationCustomHandlerTest < I18n::TestCase def setup + super @old_handler = I18n.config.missing_interpolation_argument_handler I18n.config.missing_interpolation_argument_handler = lambda do |key, values, string| "missing key is #{key}, values are #{values.inspect}, given string is '#{string}'" @@ -70,6 +71,7 @@ def setup def teardown I18n.config.missing_interpolation_argument_handler = @old_handler + super end test "String interpolation can use custom missing interpolation handler" do diff --git a/test/i18n/load_path_test.rb b/test/i18n/load_path_test.rb index ebb023e7..804aa88f 100644 --- a/test/i18n/load_path_test.rb +++ b/test/i18n/load_path_test.rb @@ -2,6 +2,7 @@ class I18nLoadPathTest < I18n::TestCase def setup + super I18n.locale = :en I18n.backend = I18n::Backend::Simple.new store_translations(:en, :foo => {:bar => 'bar', :baz => 'baz'}) diff --git a/test/i18n_test.rb b/test/i18n_test.rb index c64d595c..beaf3cdb 100644 --- a/test/i18n_test.rb +++ b/test/i18n_test.rb @@ -3,6 +3,7 @@ class I18nTest < I18n::TestCase def setup + super store_translations(:en, :currency => { :format => { :separator => '.', :delimiter => ',', } }) store_translations(:nl, :currency => { :format => { :separator => ',', :delimiter => '.', } }) end diff --git a/test/locale/fallbacks_test.rb b/test/locale/fallbacks_test.rb index b25f02d2..76a3fd14 100644 --- a/test/locale/fallbacks_test.rb +++ b/test/locale/fallbacks_test.rb @@ -5,6 +5,7 @@ class I18nFallbacksDefaultsTest < I18n::TestCase def teardown I18n.default_locale = :en + super end test "defaults reflect the I18n.default_locale if no default has been set manually" do @@ -28,6 +29,7 @@ def teardown class I18nFallbacksComputationTest < I18n::TestCase def setup + super @fallbacks = Fallbacks.new(:'en-US') end diff --git a/test/locale/tag/rfc4646_test.rb b/test/locale/tag/rfc4646_test.rb index 97fa6e45..a0f42864 100644 --- a/test/locale/tag/rfc4646_test.rb +++ b/test/locale/tag/rfc4646_test.rb @@ -35,6 +35,7 @@ class I18nLocaleTagSubtagsTest < I18n::TestCase include I18n::Locale def setup + super subtags = %w(de Latn DE variant a-ext x-phonebk i-klingon) @tag = Tag::Rfc4646.new(*subtags) end diff --git a/test/test_helper.rb b/test/test_helper.rb index d24b81f3..81b5d97f 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -42,14 +42,19 @@ def self.setup_rufus_tokyo puts "can't use KeyValue backend because: #{e.message}" end - def teardown + def setup super + I18n.enforce_available_locales = false + end + + def teardown I18n.locale = nil I18n.default_locale = :en I18n.load_path = [] I18n.available_locales = nil I18n.backend = nil - I18n.enforce_available_locales = nil + I18n.enforce_available_locales = true + super end # Ignore Test::Unit::TestCase failing if the test case does not contain any From ad9affb91b6f6f6fda845e9db4aa04d5d16029a3 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Wed, 9 Jul 2014 15:22:21 -0300 Subject: [PATCH 061/145] Tidy up chain + fallback setup logic in tests --- test/backend/fallbacks_test.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/backend/fallbacks_test.rb b/test/backend/fallbacks_test.rb index 10e11b72..76d2a798 100644 --- a/test/backend/fallbacks_test.rb +++ b/test/backend/fallbacks_test.rb @@ -125,14 +125,16 @@ class Backend < I18n::Backend::Simple include I18n::Backend::Fallbacks end + class Chain < I18n::Backend::Chain + include I18n::Backend::Fallbacks + end + def setup super backend = Backend.new backend.store_translations(:de, :foo => 'FOO') backend.store_translations(:'pt-BR', :foo => 'Baz in :pt-BR') - klass = Class.new(I18n::Backend::Chain) - klass.send :include, I18n::Backend::Fallbacks - I18n.backend = klass.new(I18n::Backend::Simple.new, backend) + I18n.backend = Chain.new(I18n::Backend::Simple.new, backend) end test "falls back from de-DE to de when there is no translation for de-DE available" do From b87f1639fdf7695ca76fa647f0818cdf9326c175 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Wed, 9 Jul 2014 15:44:42 -0300 Subject: [PATCH 062/145] Revert #default_separator on base test case Clean teardown methods a bit by relying on the base test case. --- test/gettext/backend_test.rb | 9 +-------- test/locale/fallbacks_test.rb | 5 ----- test/test_helper.rb | 5 +++-- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/test/gettext/backend_test.rb b/test/gettext/backend_test.rb index 960c1eeb..d056e1b9 100644 --- a/test/gettext/backend_test.rb +++ b/test/gettext/backend_test.rb @@ -17,14 +17,7 @@ def setup I18n.backend = Backend.new I18n.locale = :en I18n.load_path = ["#{locales_dir}/de.po"] - @old_separator, I18n.default_separator = I18n.default_separator, '|' - end - - def teardown - I18n.load_path = nil - I18n.backend = nil - I18n.default_separator = @old_separator - super + I18n.default_separator = '|' end def test_backend_loads_po_file diff --git a/test/locale/fallbacks_test.rb b/test/locale/fallbacks_test.rb index 76a3fd14..7a438523 100644 --- a/test/locale/fallbacks_test.rb +++ b/test/locale/fallbacks_test.rb @@ -3,11 +3,6 @@ include I18n::Locale class I18nFallbacksDefaultsTest < I18n::TestCase - def teardown - I18n.default_locale = :en - super - end - test "defaults reflect the I18n.default_locale if no default has been set manually" do I18n.default_locale = :'en-US' fallbacks = Fallbacks.new diff --git a/test/test_helper.rb b/test/test_helper.rb index 81b5d97f..6b4d83e0 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -49,10 +49,11 @@ def setup def teardown I18n.locale = nil - I18n.default_locale = :en - I18n.load_path = [] + I18n.default_locale = nil + I18n.load_path = nil I18n.available_locales = nil I18n.backend = nil + I18n.default_separator = nil I18n.enforce_available_locales = true super end From de08cd786a460edfd4b1b92726e1fd7bab2c104d Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Wed, 9 Jul 2014 19:47:17 -0300 Subject: [PATCH 063/145] Fix pattern to only load files under our test directory --- Rakefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Rakefile b/Rakefile index 65eb0ef1..bdc6683c 100644 --- a/Rakefile +++ b/Rakefile @@ -6,8 +6,7 @@ task :default => [:test] Rake::TestTask.new(:test) do |t| t.libs << 'lib' t.libs << 'test' - dir = File.dirname(__FILE__) - t.pattern = "#{dir}/**/*_test.rb" + t.pattern = "test/**/*_test.rb" t.verbose = true t.warning = true end From 267b15b09ded951767e13cddcb0346b1ff5c9b93 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Wed, 9 Jul 2014 20:37:44 -0300 Subject: [PATCH 064/145] Require with full file path to mimic rake so that tests pass on Ruby 1.8.7 Since the require path is different simple_test file will be loaded twice in Ruby 1.8.7, and the suite then fails with duplicated test names being defined. The solution for now is to require the file with full path, which mimics how rake requires the files and thus only loads it once. This seems to work with 1.8.7 and 1.9.3, but can be dropped as soon as 1.8.7 support is removed. --- test/backend/memoize_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/backend/memoize_test.rb b/test/backend/memoize_test.rb index a8a2e11e..0fb9f904 100644 --- a/test/backend/memoize_test.rb +++ b/test/backend/memoize_test.rb @@ -1,6 +1,6 @@ require 'test_helper' - -require 'backend/simple_test' +# TODO: change back to "require 'backend/simple'" when dropping support to Ruby 1.8.7. +require File.expand_path('../simple_test', __FILE__) class I18nBackendMemoizeTest < I18nBackendSimpleTest module MemoizeSpy From 05428e594281305bf24f3e68122ef38ab64a0294 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Thu, 10 Jul 2014 20:35:03 -0300 Subject: [PATCH 065/145] Require missing set file. Closes #270 --- lib/i18n/config.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/i18n/config.rb b/lib/i18n/config.rb index f0bb45bf..d39b1991 100644 --- a/lib/i18n/config.rb +++ b/lib/i18n/config.rb @@ -1,3 +1,5 @@ +require 'set' + module I18n class Config # The only configuration value that is not global and scoped to thread is :locale. From 0ebd3ac82a7daf6a3610dcbcd4ff94c20f2070b8 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Sun, 13 Jul 2014 19:17:05 -0300 Subject: [PATCH 066/145] Fix typo in deprecation about :rescue_format. Closes #271 [ci skip] --- lib/i18n/exceptions.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/i18n/exceptions.rb b/lib/i18n/exceptions.rb index 3e0b1c58..54039e4c 100644 --- a/lib/i18n/exceptions.rb +++ b/lib/i18n/exceptions.rb @@ -14,7 +14,7 @@ def call(exception, locale, key, options) # rescue_format is removed if options[:rescue_format] == :html if !defined?(@rescue_format_deprecation) - $stderr.puts "[DEPRECATED] I18n's :recue_format option will be removed from a future release. All exception messages will be plain text. If you need the exception handler to return an html format please set or pass a custom exception handler." + $stderr.puts "[DEPRECATED] I18n's :rescue_format option will be removed from a future release. All exception messages will be plain text. If you need the exception handler to return an html format please set or pass a custom exception handler." @rescue_format_deprecation = true end exception.html_message From 94b1705cb96cd1dbaa90d17f32754f890663e2f4 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Thu, 8 May 2014 20:43:42 -0300 Subject: [PATCH 067/145] Officially drop support to Ruby 1.8/REE and Rails < 3.2 --- .travis.yml | 23 ----------------- CHANGELOG.md | 4 +++ gemfiles/Gemfile.rails-2.3.x | 11 -------- gemfiles/Gemfile.rails-2.3.x.lock | 30 ---------------------- gemfiles/Gemfile.rails-3.0.x | 11 -------- gemfiles/Gemfile.rails-3.0.x.lock | 30 ---------------------- gemfiles/Gemfile.rails-3.1.x | 10 -------- gemfiles/Gemfile.rails-3.1.x.lock | 30 ---------------------- lib/i18n/backend/interpolation_compiler.rb | 2 +- test/api/override_test.rb | 3 +-- 10 files changed, 6 insertions(+), 148 deletions(-) create mode 100644 CHANGELOG.md delete mode 100644 gemfiles/Gemfile.rails-2.3.x delete mode 100644 gemfiles/Gemfile.rails-2.3.x.lock delete mode 100644 gemfiles/Gemfile.rails-3.0.x delete mode 100644 gemfiles/Gemfile.rails-3.0.x.lock delete mode 100644 gemfiles/Gemfile.rails-3.1.x delete mode 100644 gemfiles/Gemfile.rails-3.1.x.lock diff --git a/.travis.yml b/.travis.yml index 0fd98352..6513818f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,43 +1,20 @@ before_install: "sudo apt-get install ruby-tokyocabinet -y" rvm: - - 1.8.7 - 1.9.3 - 2.0.0 - 2.1 - - ree - rbx - jruby gemfile: - Gemfile - - gemfiles/Gemfile.rails-2.3.x - - gemfiles/Gemfile.rails-3.0.x - - gemfiles/Gemfile.rails-3.1.x - gemfiles/Gemfile.rails-3.2.x - gemfiles/Gemfile.rails-4.0.x - gemfiles/Gemfile.rails-4.1.x matrix: allow_failures: - - rvm: ree - rvm: rbx - rvm: jruby - exclude: - - gemfile: gemfiles/Gemfile.rails-2.3.x - rvm: 2.0.0 - - gemfile: gemfiles/Gemfile.rails-2.3.x - rvm: 2.1 - - gemfile: gemfiles/Gemfile.rails-2.3.x - rvm: rbx - - gemfile: gemfiles/Gemfile.rails-2.3.x - rvm: jruby - - gemfile: gemfiles/Gemfile.rails-4.0.x - rvm: 1.8.7 - - gemfile: gemfiles/Gemfile.rails-4.0.x - rvm: ree - - gemfile: gemfiles/Gemfile.rails-4.1.x - rvm: 1.8.7 - - gemfile: gemfiles/Gemfile.rails-4.1.x - rvm: ree fast_finish: true diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..f826468e --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,4 @@ +# 0.7 (unreleased) + +* Drop support to Ruby 1.8.7 / REE +* Drop support to Rails 2.3 / 3.0 / 3.1 diff --git a/gemfiles/Gemfile.rails-2.3.x b/gemfiles/Gemfile.rails-2.3.x deleted file mode 100644 index b0b1fa11..00000000 --- a/gemfiles/Gemfile.rails-2.3.x +++ /dev/null @@ -1,11 +0,0 @@ -source 'https://rubygems.org' - -gemspec :path => '..' - -gem 'activesupport', '~> 2.3' -gem 'mocha' -gem 'test_declarative' -gem 'rufus-tokyo' -gem 'ffi' -gem 'rake' -gem 'yajl-ruby' diff --git a/gemfiles/Gemfile.rails-2.3.x.lock b/gemfiles/Gemfile.rails-2.3.x.lock deleted file mode 100644 index 136d146f..00000000 --- a/gemfiles/Gemfile.rails-2.3.x.lock +++ /dev/null @@ -1,30 +0,0 @@ -PATH - remote: .. - specs: - i18n (0.6.11) - -GEM - remote: https://rubygems.org/ - specs: - activesupport (2.3.18) - ffi (1.9.3) - metaclass (0.0.4) - mocha (1.0.0) - metaclass (~> 0.0.1) - rake (10.3.1) - rufus-tokyo (1.0.7) - test_declarative (0.0.5) - yajl-ruby (1.2.0) - -PLATFORMS - ruby - -DEPENDENCIES - activesupport (~> 2.3) - ffi - i18n! - mocha - rake - rufus-tokyo - test_declarative - yajl-ruby diff --git a/gemfiles/Gemfile.rails-3.0.x b/gemfiles/Gemfile.rails-3.0.x deleted file mode 100644 index 59fcf0e3..00000000 --- a/gemfiles/Gemfile.rails-3.0.x +++ /dev/null @@ -1,11 +0,0 @@ -source 'https://rubygems.org' - -gemspec :path => '..' - -gem 'activesupport', '~> 3.0.0' -gem 'mocha' -gem 'test_declarative' -gem 'rufus-tokyo' -gem 'ffi' -gem 'rake' -gem 'yajl-ruby' diff --git a/gemfiles/Gemfile.rails-3.0.x.lock b/gemfiles/Gemfile.rails-3.0.x.lock deleted file mode 100644 index d0e85b9a..00000000 --- a/gemfiles/Gemfile.rails-3.0.x.lock +++ /dev/null @@ -1,30 +0,0 @@ -PATH - remote: .. - specs: - i18n (0.6.11) - -GEM - remote: https://rubygems.org/ - specs: - activesupport (3.0.20) - ffi (1.9.3) - metaclass (0.0.4) - mocha (1.0.0) - metaclass (~> 0.0.1) - rake (10.3.1) - rufus-tokyo (1.0.7) - test_declarative (0.0.5) - yajl-ruby (1.2.0) - -PLATFORMS - ruby - -DEPENDENCIES - activesupport (~> 3.0.0) - ffi - i18n! - mocha - rake - rufus-tokyo - test_declarative - yajl-ruby diff --git a/gemfiles/Gemfile.rails-3.1.x b/gemfiles/Gemfile.rails-3.1.x deleted file mode 100644 index 98174c4f..00000000 --- a/gemfiles/Gemfile.rails-3.1.x +++ /dev/null @@ -1,10 +0,0 @@ -source 'https://rubygems.org' - -gemspec :path => '..' - -gem 'activesupport', '~> 3.1.0' -gem 'mocha' -gem 'test_declarative' -gem 'rufus-tokyo' -gem 'ffi' -gem 'rake' diff --git a/gemfiles/Gemfile.rails-3.1.x.lock b/gemfiles/Gemfile.rails-3.1.x.lock deleted file mode 100644 index 9b165588..00000000 --- a/gemfiles/Gemfile.rails-3.1.x.lock +++ /dev/null @@ -1,30 +0,0 @@ -PATH - remote: .. - specs: - i18n (0.6.11) - -GEM - remote: https://rubygems.org/ - specs: - activesupport (3.1.12) - multi_json (~> 1.0) - ffi (1.9.3) - metaclass (0.0.4) - mocha (1.0.0) - metaclass (~> 0.0.1) - multi_json (1.10.0) - rake (10.3.1) - rufus-tokyo (1.0.7) - test_declarative (0.0.5) - -PLATFORMS - ruby - -DEPENDENCIES - activesupport (~> 3.1.0) - ffi - i18n! - mocha - rake - rufus-tokyo - test_declarative diff --git a/lib/i18n/backend/interpolation_compiler.rb b/lib/i18n/backend/interpolation_compiler.rb index c5440704..0e3a603a 100644 --- a/lib/i18n/backend/interpolation_compiler.rb +++ b/lib/i18n/backend/interpolation_compiler.rb @@ -12,7 +12,7 @@ # # Note that InterpolationCompiler does not yield meaningful results and consequently # should not be used with Ruby 1.9 (YARV) but improves performance everywhere else -# (jRuby, Rubinius and 1.8.7). +# (jRuby, Rubinius). module I18n module Backend module InterpolationCompiler diff --git a/test/api/override_test.rb b/test/api/override_test.rb index e8cb29c9..6e1248ad 100644 --- a/test/api/override_test.rb +++ b/test/api/override_test.rb @@ -26,8 +26,7 @@ def setup @I18n.backend.store_translations('en', :foo => 'bar') assert_equal 'rab', @I18n.translate(:foo, :locale => 'en') - # FIXME: this fails under 1.8.7 - # assert_equal 'rab', @I18n.t(:foo, :locale => 'en') + assert_equal 'rab', @I18n.t(:foo, :locale => 'en') assert_equal 'rab', @I18n.translate!(:foo, :locale => 'en') assert_equal 'rab', @I18n.t!(:foo, :locale => 'en') end From 353e2446123c2e30b542f9a569ad488fd7f7e861 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Thu, 8 May 2014 20:53:54 -0300 Subject: [PATCH 068/145] Remove string interpolation backport for Ruby 1.8 Now that 1.8 has been officially dropped, we can remove this extension. --- lib/i18n/core_ext/string/interpolate.rb | 105 ----------------------- test/core_ext/string/interpolate_test.rb | 99 --------------------- test/i18n/interpolate_test.rb | 1 - 3 files changed, 205 deletions(-) delete mode 100644 lib/i18n/core_ext/string/interpolate.rb delete mode 100644 test/core_ext/string/interpolate_test.rb diff --git a/lib/i18n/core_ext/string/interpolate.rb b/lib/i18n/core_ext/string/interpolate.rb deleted file mode 100644 index 56de8c00..00000000 --- a/lib/i18n/core_ext/string/interpolate.rb +++ /dev/null @@ -1,105 +0,0 @@ -# This backports the Ruby 1.9 String interpolation syntax to Ruby 1.8. -# -# This backport has been shipped with I18n for a number of versions. Meanwhile -# Rails has started to rely on it and we are going to move it to ActiveSupport. -# See https://rails.lighthouseapp.com/projects/8994/tickets/6013-move-19-string-interpolation-syntax-backport-from-i18n-to-activesupport -# -# Once the above patch has been applied to Rails the following code will be -# removed from I18n. - -=begin - heavily based on Masao Mutoh's gettext String interpolation extension - http://github.com/mutoh/gettext/blob/f6566738b981fe0952548c421042ad1e0cdfb31e/lib/gettext/core_ext/string.rb - Copyright (C) 2005-2009 Masao Mutoh - You may redistribute it and/or modify it under the same license terms as Ruby. -=end - -begin - raise ArgumentError if ("a %{x}" % {:x=>'b'}) != 'a b' -rescue ArgumentError - # KeyError is raised by String#% when the string contains a named placeholder - # that is not contained in the given arguments hash. Ruby 1.9 includes and - # raises this exception natively. We define it to mimic Ruby 1.9's behaviour - # in Ruby 1.8.x - class KeyError < IndexError - def initialize(message = nil) - super(message || "key not found") - end - end unless defined?(KeyError) - - # Extension for String class. This feature is included in Ruby 1.9 or later but not occur TypeError. - # - # String#% method which accept "named argument". The translator can know - # the meaning of the msgids using "named argument" instead of %s/%d style. - class String - # For older ruby versions, such as ruby-1.8.5 - alias :bytesize :size unless instance_methods.find {|m| m.to_s == 'bytesize'} - alias :interpolate_without_ruby_19_syntax :% # :nodoc: - - INTERPOLATION_PATTERN = Regexp.union( - /%\{(\w+)\}/, # matches placeholders like "%{foo}" - /%<(\w+)>(.*?\d*\.?\d*[bBdiouxXeEfgGcps])/ # matches placeholders like "%.d" - ) - - INTERPOLATION_PATTERN_WITH_ESCAPE = Regexp.union( - /%%/, - INTERPOLATION_PATTERN - ) - - # % uses self (i.e. the String) as a format specification and returns the - # result of applying it to the given arguments. In other words it interpolates - # the given arguments to the string according to the formats the string - # defines. - # - # There are three ways to use it: - # - # * Using a single argument or Array of arguments. - # - # This is the default behaviour of the String class. See Kernel#sprintf for - # more details about the format string. - # - # Example: - # - # "%d %s" % [1, "message"] - # # => "1 message" - # - # * Using a Hash as an argument and unformatted, named placeholders. - # - # When you pass a Hash as an argument and specify placeholders with %{foo} - # it will interpret the hash values as named arguments. - # - # Example: - # - # "%{firstname}, %{lastname}" % {:firstname => "Masao", :lastname => "Mutoh"} - # # => "Masao Mutoh" - # - # * Using a Hash as an argument and formatted, named placeholders. - # - # When you pass a Hash as an argument and specify placeholders with %d - # it will interpret the hash values as named arguments and format the value - # according to the formatting instruction appended to the closing >. - # - # Example: - # - # "%d, %.1f" % { :integer => 10, :float => 43.4 } - # # => "10, 43.3" - def %(args) - if args.kind_of?(Hash) - dup.gsub(INTERPOLATION_PATTERN_WITH_ESCAPE) do |match| - if match == '%%' - '%' - else - key = ($1 || $2).to_sym - raise KeyError unless args.has_key?(key) - $3 ? sprintf("%#{$3}", args[key]) : args[key] - end - end - elsif self =~ INTERPOLATION_PATTERN - raise ArgumentError.new('one hash required') - else - result = gsub(/%([{<])/, '%%\1') - result.send :'interpolate_without_ruby_19_syntax', args - end - end - end -end diff --git a/test/core_ext/string/interpolate_test.rb b/test/core_ext/string/interpolate_test.rb deleted file mode 100644 index a1ed9c4c..00000000 --- a/test/core_ext/string/interpolate_test.rb +++ /dev/null @@ -1,99 +0,0 @@ -require 'test_helper' - -# thanks to Masao's String extensions these should work the same in -# Ruby 1.8 (patched) and Ruby 1.9 (native) -# some tests taken from Masao's tests -# http://github.com/mutoh/gettext/blob/edbbe1fa8238fa12c7f26f2418403015f0270e47/test/test_string.rb - -class I18nCoreExtStringInterpolationTest < I18n::TestCase - test "String interpolates a single argument" do - assert_equal "Masao", "%s" % "Masao" - end - - test "String interpolates an array argument" do - assert_equal "1 message", "%d %s" % [1, 'message'] - end - - test "String interpolates a hash argument w/ named placeholders" do - assert_equal "Masao Mutoh", "%{first} %{last}" % { :first => 'Masao', :last => 'Mutoh' } - end - - test "String interpolates a hash argument w/ named placeholders (reverse order)" do - assert_equal "Mutoh, Masao", "%{last}, %{first}" % { :first => 'Masao', :last => 'Mutoh' } - end - - test "String interpolates named placeholders with sprintf syntax" do - assert_equal "10, 43.4", "%d, %.1f" % {:integer => 10, :float => 43.4} - end - - test "String interpolates named placeholders with sprintf syntax, does not recurse" do - assert_equal "%s", "%{msg}" % { :msg => '%s', :not_translated => 'should not happen' } - end - - test "String interpolation does not replace anything when no placeholders are given" do - assert_equal("aaa", "aaa" % {:num => 1}) - assert_equal("bbb", "bbb" % [1]) - end - - test "String interpolation sprintf behaviour equals Ruby 1.9 behaviour" do - assert_equal("1", "%d" % {:num => 1}) - assert_equal("0b1", "%#b" % {:num => 1}) - assert_equal("foo", "%s" % {:msg => "foo"}) - assert_equal("1.000000", "%f" % {:num => 1.0}) - assert_equal(" 1", "%3.0f" % {:num => 1.0}) - assert_equal("100.00", "%2.2f" % {:num => 100.0}) - assert_equal("0x64", "%#x" % {:num => 100.0}) - assert_raise(ArgumentError) { "%,d" % {:num => 100} } - assert_raise(ArgumentError) { "%/d" % {:num => 100} } - end - - test "String interpolation old-style sprintf still works" do - assert_equal("foo 1.000000", "%s %f" % ["foo", 1.0]) - end - - test "String interpolation raises an ArgumentError when the string has extra placeholders (Array)" do - assert_raise(ArgumentError) do # Ruby 1.9 msg: "too few arguments" - "%s %s" % %w(Masao) - end - end - - test "String interpolation raises a KeyError when the string has extra placeholders (Hash)" do - assert_raise(KeyError) do # Ruby 1.9 msg: "key not found" - "%{first} %{last}" % { :first => 'Masao' } - end - end - - test "String interpolation does not raise when passed extra values (Array)" do - assert_nothing_raised do - assert_equal "Masao", "%s" % %w(Masao Mutoh) - end - end - - test "String interpolation does not raise when passed extra values (Hash)" do - assert_nothing_raised do - assert_equal "Masao Mutoh", "%{first} %{last}" % { :first => 'Masao', :last => 'Mutoh', :salutation => 'Mr.' } - end - end - - test "% acts as escape character in String interpolation" do - assert_equal "%{first}", "%%{first}" % { :first => 'Masao' } - assert_equal("% 1", "%% %d" % {:num => 1.0}) - assert_equal("%{num} %d", "%%{num} %%d" % {:num => 1}) - end - - test "% can be used in Ruby's own sprintf behavior" do - assert_equal "70%", "%d%%" % 70 - assert_equal "70-100%", "%d-%d%%" % [70, 100] - assert_equal "+2.30%", "%+.2f%%" % 2.3 - end - - def test_sprintf_mix_unformatted_and_formatted_named_placeholders - assert_equal("foo 1.000000", "%{name} %f" % {:name => "foo", :num => 1.0}) - end - - def test_string_interpolation_raises_an_argument_error_when_mixing_named_and_unnamed_placeholders - assert_raise(ArgumentError) { "%{name} %f" % [1.0] } - assert_raise(ArgumentError) { "%{name} %f" % [1.0, 2.0] } - end -end - diff --git a/test/i18n/interpolate_test.rb b/test/i18n/interpolate_test.rb index cb80908f..4bc63926 100644 --- a/test/i18n/interpolate_test.rb +++ b/test/i18n/interpolate_test.rb @@ -1,5 +1,4 @@ require 'test_helper' -require 'i18n/core_ext/string/interpolate' # thanks to Masao's String extensions, some tests taken from Masao's tests # http://github.com/mutoh/gettext/blob/edbbe1fa8238fa12c7f26f2418403015f0270e47/test/test_string.rb From 6e3d1bae624345e7d996534925ccc0db3bd4d40c Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Thu, 8 May 2014 21:03:00 -0300 Subject: [PATCH 069/145] Remove more dead code related to Ruby version compatibility --- lib/i18n.rb | 2 - test/backend/transliterator_test.rb | 8 +- test/gettext/backend_test.rb | 150 ++++++++++++++-------------- test/test_helper.rb | 2 - 4 files changed, 76 insertions(+), 86 deletions(-) diff --git a/lib/i18n.rb b/lib/i18n.rb index 98b65bf3..afc43347 100644 --- a/lib/i18n.rb +++ b/lib/i18n.rb @@ -286,8 +286,6 @@ def enforce_available_locales!(locale) end end - # making these private until Ruby 1.9.2 can send to protected methods again - # see http://redmine.ruby-lang.org/repositories/revision/ruby-19?rev=24280 private # Any exceptions thrown in translate will be sent to the @@exception_handler diff --git a/test/backend/transliterator_test.rb b/test/backend/transliterator_test.rb index 89e99735..c40e2bbf 100644 --- a/test/backend/transliterator_test.rb +++ b/test/backend/transliterator_test.rb @@ -56,11 +56,9 @@ def setup assert_equal "abc#", @transliterator.transliterate("abcſ", "#") end - if RUBY_VERSION >= "1.9" - test "default transliterator raises errors for invalid UTF-8" do - assert_raise ArgumentError do - @transliterator.transliterate("a\x92b") - end + test "default transliterator raises errors for invalid UTF-8" do + assert_raise ArgumentError do + @transliterator.transliterate("a\x92b") end end diff --git a/test/gettext/backend_test.rb b/test/gettext/backend_test.rb index d056e1b9..30254e6b 100644 --- a/test/gettext/backend_test.rb +++ b/test/gettext/backend_test.rb @@ -2,95 +2,91 @@ require 'test_helper' -# apparently Ruby 1.9.1p129 has encoding problems with the gettext po parser -unless RUBY_VERSION == '1.9.1' && RUBY_PATCHLEVEL <= 129 +class I18nGettextBackendTest < I18n::TestCase + include I18n::Gettext::Helpers - class I18nGettextBackendTest < I18n::TestCase - include I18n::Gettext::Helpers - - class Backend < I18n::Backend::Simple - include I18n::Backend::Gettext - end + class Backend < I18n::Backend::Simple + include I18n::Backend::Gettext + end - def setup - super - I18n.backend = Backend.new - I18n.locale = :en - I18n.load_path = ["#{locales_dir}/de.po"] - I18n.default_separator = '|' - end + def setup + super + I18n.backend = Backend.new + I18n.locale = :en + I18n.load_path = ["#{locales_dir}/de.po"] + I18n.default_separator = '|' + end - def test_backend_loads_po_file - I18n.backend.send(:init_translations) - assert I18n.backend.send(:translations)[:de][:"Axis"] - end + def test_backend_loads_po_file + I18n.backend.send(:init_translations) + assert I18n.backend.send(:translations)[:de][:"Axis"] + end - def test_looks_up_a_translation - I18n.locale = :de - assert_equal 'Auto', gettext('car') - end + def test_looks_up_a_translation + I18n.locale = :de + assert_equal 'Auto', gettext('car') + end - def test_uses_default_translation - assert_equal 'car', gettext('car') - end + def test_uses_default_translation + assert_equal 'car', gettext('car') + end - def test_looks_up_a_namespaced_translation - I18n.locale = :de - assert_equal 'Räderzahl', sgettext('Car|Wheels count') - assert_equal 'Räderzahl', pgettext('Car', 'Wheels count') - assert_equal 'Räderzahl!', pgettext('New car', 'Wheels count') - end + def test_looks_up_a_namespaced_translation + I18n.locale = :de + assert_equal 'Räderzahl', sgettext('Car|Wheels count') + assert_equal 'Räderzahl', pgettext('Car', 'Wheels count') + assert_equal 'Räderzahl!', pgettext('New car', 'Wheels count') + end - def test_uses_namespaced_default_translation - assert_equal 'Wheels count', sgettext('Car|Wheels count') - assert_equal 'Wheels count', pgettext('Car', 'Wheels count') - assert_equal 'Wheels count', pgettext('New car', 'Wheels count') - end + def test_uses_namespaced_default_translation + assert_equal 'Wheels count', sgettext('Car|Wheels count') + assert_equal 'Wheels count', pgettext('Car', 'Wheels count') + assert_equal 'Wheels count', pgettext('New car', 'Wheels count') + end - def test_pluralizes_entry - I18n.locale = :de - assert_equal 'Achse', ngettext('Axis', 'Axis', 1) - assert_equal 'Achsen', ngettext('Axis', 'Axis', 2) - end + def test_pluralizes_entry + I18n.locale = :de + assert_equal 'Achse', ngettext('Axis', 'Axis', 1) + assert_equal 'Achsen', ngettext('Axis', 'Axis', 2) + end - def test_pluralizes_default_entry - assert_equal 'Axis', ngettext('Axis', 'Axis', 1) - assert_equal 'Axis', ngettext('Axis', 'Axis', 2) - end + def test_pluralizes_default_entry + assert_equal 'Axis', ngettext('Axis', 'Axis', 1) + assert_equal 'Axis', ngettext('Axis', 'Axis', 2) + end - def test_pluralizes_namespaced_entry - I18n.locale = :de - assert_equal 'Rad', nsgettext('Car|wheel', 'wheels', 1) - assert_equal 'Räder', nsgettext('Car|wheel', 'wheels', 2) - assert_equal 'Rad', npgettext('Car', 'wheel', 'wheels', 1) - assert_equal 'Räder', npgettext('Car', 'wheel', 'wheels', 2) - assert_equal 'Rad!', npgettext('New car', 'wheel', 'wheels', 1) - assert_equal 'Räder!', npgettext('New car', 'wheel', 'wheels', 2) - end + def test_pluralizes_namespaced_entry + I18n.locale = :de + assert_equal 'Rad', nsgettext('Car|wheel', 'wheels', 1) + assert_equal 'Räder', nsgettext('Car|wheel', 'wheels', 2) + assert_equal 'Rad', npgettext('Car', 'wheel', 'wheels', 1) + assert_equal 'Räder', npgettext('Car', 'wheel', 'wheels', 2) + assert_equal 'Rad!', npgettext('New car', 'wheel', 'wheels', 1) + assert_equal 'Räder!', npgettext('New car', 'wheel', 'wheels', 2) + end - def test_pluralizes_namespaced_default_entry - assert_equal 'wheel', nsgettext('Car|wheel', 'wheels', 1) - assert_equal 'wheels', nsgettext('Car|wheel', 'wheels', 2) - assert_equal 'wheel', npgettext('Car', 'wheel', 'wheels', 1) - assert_equal 'wheels', npgettext('Car', 'wheel', 'wheels', 2) - assert_equal 'wheel', npgettext('New car', 'wheel', 'wheels', 1) - assert_equal 'wheels', npgettext('New car', 'wheel', 'wheels', 2) - end + def test_pluralizes_namespaced_default_entry + assert_equal 'wheel', nsgettext('Car|wheel', 'wheels', 1) + assert_equal 'wheels', nsgettext('Car|wheel', 'wheels', 2) + assert_equal 'wheel', npgettext('Car', 'wheel', 'wheels', 1) + assert_equal 'wheels', npgettext('Car', 'wheel', 'wheels', 2) + assert_equal 'wheel', npgettext('New car', 'wheel', 'wheels', 1) + assert_equal 'wheels', npgettext('New car', 'wheel', 'wheels', 2) + end - def test_pluralizes_namespaced_entry_with_alternative_syntax - I18n.locale = :de - assert_equal 'Rad', nsgettext(['Car|wheel', 'wheels'], 1) - assert_equal 'Räder', nsgettext(['Car|wheel', 'wheels'], 2) - assert_equal 'Rad', npgettext('Car', ['wheel', 'wheels'], 1) - assert_equal 'Räder', npgettext('Car', ['wheel', 'wheels'], 2) - assert_equal 'Rad!', npgettext('New car', ['wheel', 'wheels'], 1) - assert_equal 'Räder!', npgettext('New car', ['wheel', 'wheels'], 2) - end + def test_pluralizes_namespaced_entry_with_alternative_syntax + I18n.locale = :de + assert_equal 'Rad', nsgettext(['Car|wheel', 'wheels'], 1) + assert_equal 'Räder', nsgettext(['Car|wheel', 'wheels'], 2) + assert_equal 'Rad', npgettext('Car', ['wheel', 'wheels'], 1) + assert_equal 'Räder', npgettext('Car', ['wheel', 'wheels'], 2) + assert_equal 'Rad!', npgettext('New car', ['wheel', 'wheels'], 1) + assert_equal 'Räder!', npgettext('New car', ['wheel', 'wheels'], 2) + end - def test_ngettextpluralizes_entry_with_dots - I18n.locale = :de - assert_equal 'Auf 1 Achse.', n_("On %{count} wheel.", "On %{count} wheels.", 1) - assert_equal 'Auf 2 Achsen.', n_("On %{count} wheel.", "On %{count} wheels.", 2) - end + def test_ngettextpluralizes_entry_with_dots + I18n.locale = :de + assert_equal 'Auf 1 Achse.', n_("On %{count} wheel.", "On %{count} wheels.", 1) + assert_equal 'Auf 2 Achsen.', n_("On %{count} wheel.", "On %{count} wheels.", 2) end end diff --git a/test/test_helper.rb b/test/test_helper.rb index 6b4d83e0..79cf4f04 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,7 +1,5 @@ $KCODE = 'u' if RUBY_VERSION <= '1.9' -require 'rubygems' - # Use minitest if we can, otherwise fallback to test-unit. begin require 'minitest/autorun' From ccbc14e88e2398dea2af8ae1b62b191fe18a033a Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Thu, 8 May 2014 20:23:52 -0300 Subject: [PATCH 070/145] Remove deprecated :default_exception_handler method --- CHANGELOG.md | 2 ++ lib/i18n.rb | 17 +++++------------ lib/i18n/config.rb | 3 ++- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f826468e..25a7fab4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,3 +2,5 @@ * Drop support to Ruby 1.8.7 / REE * Drop support to Rails 2.3 / 3.0 / 3.1 +* Remove deprecated stuff: + - Setting `:default_exception_hander` Symbol to `I18n.exception_handler`. diff --git a/lib/i18n.rb b/lib/i18n.rb index afc43347..7fdb2f7a 100644 --- a/lib/i18n.rb +++ b/lib/i18n.rb @@ -298,18 +298,18 @@ def enforce_available_locales!(locale) # # Examples: # - # I18n.exception_handler = :default_exception_handler # this is the default - # I18n.default_exception_handler(exception, locale, key, options) # will be called like this + # I18n.exception_handler = :custom_exception_handler # this is the default + # I18n.custom_exception_handler(exception, locale, key, options) # will be called like this # # I18n.exception_handler = lambda { |*args| ... } # a lambda # I18n.exception_handler.call(exception, locale, key, options) # will be called like this # - # I18n.exception_handler = I18nExceptionHandler.new # an object - # I18n.exception_handler.call(exception, locale, key, options) # will be called like this + # I18n.exception_handler = I18nExceptionHandler.new # an object + # I18n.exception_handler.call(exception, locale, key, options) # will be called like this def handle_exception(handling, exception, locale, key, options) case handling when :raise - raise(exception.respond_to?(:to_exception) ? exception.to_exception : exception) + raise exception.respond_to?(:to_exception) ? exception.to_exception : exception when :throw throw :exception, exception else @@ -345,13 +345,6 @@ def normalize_translation_keys(locale, key, scope, separator = nil) normalize_keys(locale, key, scope, separator) end - # DEPRECATED. Please use the I18n::ExceptionHandler class instead. - def default_exception_handler(exception, locale, key, options) - puts "I18n.default_exception_handler is deprecated. Please use the class I18n::ExceptionHandler instead " + - "(an instance of which is set to I18n.exception_handler by default)." - exception.is_a?(MissingTranslation) ? exception.message : raise(exception) - end - def handle_enforce_available_locales_deprecation if config.enforce_available_locales.nil? && !defined?(@unenforced_available_locales_deprecation) $stderr.puts "[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message." diff --git a/lib/i18n/config.rb b/lib/i18n/config.rb index d39b1991..30a43475 100644 --- a/lib/i18n/config.rb +++ b/lib/i18n/config.rb @@ -68,7 +68,8 @@ def default_separator=(separator) @@default_separator = separator end - # Return the current exception handler. Defaults to :default_exception_handler. + # Returns the current exception handler. Defaults to an instance of + # I18n::ExceptionHandler. def exception_handler @@exception_handler ||= ExceptionHandler.new end From 1108de879d870e03778e08070dea956e0738c0f4 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Thu, 8 May 2014 20:25:28 -0300 Subject: [PATCH 071/145] Remove deprecated normalize_translation_keys --- CHANGELOG.md | 1 + lib/i18n.rb | 6 ------ 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 25a7fab4..59dede93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,3 +4,4 @@ * Drop support to Rails 2.3 / 3.0 / 3.1 * Remove deprecated stuff: - Setting `:default_exception_hander` Symbol to `I18n.exception_handler`. + - `normalize_translation_keys` in favor of `normalize_keys`. diff --git a/lib/i18n.rb b/lib/i18n.rb index 7fdb2f7a..439f901d 100644 --- a/lib/i18n.rb +++ b/lib/i18n.rb @@ -339,12 +339,6 @@ def normalized_key_cache @normalized_key_cache ||= Hash.new { |h,k| h[k] = {} } end - # DEPRECATED. Use I18n.normalize_keys instead. - def normalize_translation_keys(locale, key, scope, separator = nil) - puts "I18n.normalize_translation_keys is deprecated. Please use the class I18n.normalize_keys instead." - normalize_keys(locale, key, scope, separator) - end - def handle_enforce_available_locales_deprecation if config.enforce_available_locales.nil? && !defined?(@unenforced_available_locales_deprecation) $stderr.puts "[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message." From 6db64030a3039abaf0741203e742ad899228154a Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Thu, 8 May 2014 20:36:13 -0300 Subject: [PATCH 072/145] Remove deprecated :rescue_format from exception handler --- CHANGELOG.md | 1 + lib/i18n.rb | 2 +- lib/i18n/exceptions.rb | 27 +-------------------------- test/i18n/exceptions_test.rb | 15 --------------- 4 files changed, 3 insertions(+), 42 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59dede93..1981e6d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,3 +5,4 @@ * Remove deprecated stuff: - Setting `:default_exception_hander` Symbol to `I18n.exception_handler`. - `normalize_translation_keys` in favor of `normalize_keys`. + - `:rescue_format` option on the exception handler. diff --git a/lib/i18n.rb b/lib/i18n.rb index 439f901d..f5b3ed48 100644 --- a/lib/i18n.rb +++ b/lib/i18n.rb @@ -9,7 +9,7 @@ module I18n autoload :Locale, 'i18n/locale' autoload :Tests, 'i18n/tests' - RESERVED_KEYS = [:scope, :default, :separator, :resolve, :object, :fallback, :format, :cascade, :throw, :raise, :rescue_format] + RESERVED_KEYS = [:scope, :default, :separator, :resolve, :object, :fallback, :format, :cascade, :throw, :raise] RESERVED_KEYS_PATTERN = /%\{(#{RESERVED_KEYS.join("|")})\}/ extend(Module.new { diff --git a/lib/i18n/exceptions.rb b/lib/i18n/exceptions.rb index 54039e4c..396b632d 100644 --- a/lib/i18n/exceptions.rb +++ b/lib/i18n/exceptions.rb @@ -9,19 +9,7 @@ class ExceptionHandler include Module.new { def call(exception, locale, key, options) if exception.is_a?(MissingTranslation) - # - # TODO: this block is to be replaced by `exception.message` when - # rescue_format is removed - if options[:rescue_format] == :html - if !defined?(@rescue_format_deprecation) - $stderr.puts "[DEPRECATED] I18n's :rescue_format option will be removed from a future release. All exception messages will be plain text. If you need the exception handler to return an html format please set or pass a custom exception handler." - @rescue_format_deprecation = true - end - exception.html_message - else - exception.message - end - + exception.message elsif exception.is_a?(Exception) raise exception else @@ -58,12 +46,6 @@ def initialize(locale, key, options = nil) options.each { |k, v| self.options[k] = v.inspect if v.is_a?(Proc) } end - def html_message - key = CGI.escapeHTML titleize(keys.last) - path = CGI.escapeHTML keys.join('.') - %(#{key}) - end - def keys @keys ||= I18n.normalize_keys(locale, key, options[:scope]).tap do |keys| keys << 'no key' if keys.size < 2 @@ -78,13 +60,6 @@ def message def to_exception MissingTranslationData.new(locale, key, options) end - - protected - - # TODO : remove when #html_message is removed - def titleize(key) - key.to_s.gsub('_', ' ').gsub(/\b('?[a-z])/) { $1.capitalize } - end end include Base diff --git a/test/i18n/exceptions_test.rb b/test/i18n/exceptions_test.rb index e633d7d9..d8f21602 100644 --- a/test/i18n/exceptions_test.rb +++ b/test/i18n/exceptions_test.rb @@ -27,21 +27,6 @@ def test_invalid_locale_stores_locale end end - test "MissingTranslationData html_message is a span with the titlelized last key token" do - exception = I18n::MissingTranslationData.new(:de, :foo, :scope => :bar) - assert_equal 'Foo', exception.html_message - end - - test "MissingTranslationData html_message html escapes key names" do - exception = I18n::MissingTranslationData.new(:de, '', :scope => '