diff --git a/lib/i18n.rb b/lib/i18n.rb index 4dd14704..8cceec4c 100644 --- a/lib/i18n.rb +++ b/lib/i18n.rb @@ -202,7 +202,7 @@ def translate(key = nil, *, throw: false, raise: false, locale: nil, **options) # Wrapper for translate that adds :raise => true. With # this option, if no translation is found, it will raise I18n::MissingTranslationData def translate!(key, options = EMPTY_HASH) - translate(key, options.merge(:raise => true)) + translate(key, **options.merge(:raise => true)) end alias :t! :translate! diff --git a/lib/i18n/backend/base.rb b/lib/i18n/backend/base.rb index ad5e0863..497f69b9 100644 --- a/lib/i18n/backend/base.rb +++ b/lib/i18n/backend/base.rb @@ -81,7 +81,7 @@ def localize(locale, object, format = :default, options = EMPTY_HASH) key = format type = object.respond_to?(:sec) ? 'time' : 'date' options = options.merge(:raise => true, :object => object, :locale => locale) - format = I18n.t(:"#{type}.formats.#{key}", options) + format = I18n.t(:"#{type}.formats.#{key}", **options) end format = translate_localization_format(locale, object, format, options) @@ -143,7 +143,7 @@ def resolve(locale, object, subject, options = EMPTY_HASH) result = catch(:exception) do case subject when Symbol - I18n.translate(subject, options.merge(:locale => locale, :throw => true)) + I18n.translate(subject, **options.merge(:locale => locale, :throw => true)) when Proc date_or_time = options.delete(:object) || object resolve(locale, object, subject.call(date_or_time, options)) diff --git a/lib/i18n/gettext/helpers.rb b/lib/i18n/gettext/helpers.rb index 309f555e..d077619f 100644 --- a/lib/i18n/gettext/helpers.rb +++ b/lib/i18n/gettext/helpers.rb @@ -19,7 +19,7 @@ def N_(msgsid) end def gettext(msgid, options = EMPTY_HASH) - I18n.t(msgid, { :default => msgid, :separator => '|' }.merge(options)) + I18n.t(msgid, **{:default => msgid, :separator => '|'}.merge(options)) end alias _ gettext diff --git a/lib/i18n/tests/localization/date.rb b/lib/i18n/tests/localization/date.rb index 9b930720..34fd7a33 100644 --- a/lib/i18n/tests/localization/date.rb +++ b/lib/i18n/tests/localization/date.rb @@ -68,9 +68,9 @@ def setup test "localize Date: does not modify the options hash" do options = { :format => '%b', :locale => :de } - assert_equal 'Mär', I18n.l(@date, options) + assert_equal 'Mär', I18n.l(@date, **options) assert_equal({ :format => '%b', :locale => :de }, options) - assert_nothing_raised { I18n.l(@date, options.freeze) } + assert_nothing_raised { I18n.l(@date, **options.freeze) } end test "localize Date: given nil with default value it returns default" do diff --git a/lib/i18n/tests/localization/procs.rb b/lib/i18n/tests/localization/procs.rb index de624888..c5e55232 100644 --- a/lib/i18n/tests/localization/procs.rb +++ b/lib/i18n/tests/localization/procs.rb @@ -59,7 +59,7 @@ module Procs setup_time_proc_translations time = ::Time.utc(2008, 3, 1, 6, 0) options = { :foo => 'foo' } - assert_equal I18n::Tests::Localization::Procs.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 diff --git a/lib/i18n/tests/lookup.rb b/lib/i18n/tests/lookup.rb index 3b4c8434..61e16cdd 100644 --- a/lib/i18n/tests/lookup.rb +++ b/lib/i18n/tests/lookup.rb @@ -43,9 +43,9 @@ def setup test "lookup: does not modify the options hash" do options = {} - assert_equal "a", I18n.t(:string, options) + assert_equal "a", I18n.t(:string, **options) assert_equal({}, options) - assert_nothing_raised { I18n.t(:string, options.freeze) } + assert_nothing_raised { I18n.t(:string, **options.freeze) } end test "lookup: given an array of keys it translates all of them" do diff --git a/test/api/override_test.rb b/test/api/override_test.rb index 6e1248ad..1345bbc1 100644 --- a/test/api/override_test.rb +++ b/test/api/override_test.rb @@ -2,8 +2,8 @@ class I18nOverrideTest < I18n::TestCase module OverrideInverse - def translate(*args) - super(*args).reverse + def translate(*args, **options) + super(*args, **options).reverse end alias :t :translate end diff --git a/test/backend/cascade_test.rb b/test/backend/cascade_test.rb index 11014605..23ea80e2 100644 --- a/test/backend/cascade_test.rb +++ b/test/backend/cascade_test.rb @@ -13,7 +13,7 @@ def setup end def lookup(key, options = {}) - I18n.t(key, options.merge(:cascade => @cascade_options)) + I18n.t(key, **options.merge(:cascade => @cascade_options)) end test "still returns an existing translation as usual" do diff --git a/test/i18n/exceptions_test.rb b/test/i18n/exceptions_test.rb index 84e1c8fc..1c37cdb2 100644 --- a/test/i18n/exceptions_test.rb +++ b/test/i18n/exceptions_test.rb @@ -89,7 +89,7 @@ def force_invalid_locale def force_missing_translation_data(options = {}) store_translations('de', :bar => nil) - I18n.translate(:foo, options.merge(:scope => :bar, :locale => :de)) + I18n.translate(:foo, **options.merge(:scope => :bar, :locale => :de)) rescue I18n::ArgumentError => e block_given? ? yield(e) : raise(e) end