Hello community, here is the log from the commit of package rubygem-i18n for openSUSE:Factory checked in at 2020-06-19 17:26:19 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-i18n (Old) and /work/SRC/openSUSE:Factory/.rubygem-i18n.new.3606 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-i18n" Fri Jun 19 17:26:19 2020 rev:27 rq:815945 version:1.8.3 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-i18n/rubygem-i18n.changes 2020-01-27 20:18:18.188554231 +0100 +++ /work/SRC/openSUSE:Factory/.rubygem-i18n.new.3606/rubygem-i18n.changes 2020-06-19 17:26:40.672469019 +0200 @@ -1,0 +2,18 @@ +Fri Jun 5 10:15:22 UTC 2020 - Dan Čermák <dcer...@suse.com> + +- New upstream release 1.8.3 + + Features / Improvements + + * Memory and speed improvements - #527+ #528 + * Add option to disable fallbacks for I18n.exists? check - #482 + * Add an on_fallback hook to allow users to be notified when a fallback happens - #520 + + Bug Fixes + + * Fix an issue with deep_merge and chain fallback backends - #499 & #509 + * Fix an issue with Rails ordinal number proc and keyword splatting - #521 + * Pass options as keyword arguments to translation procs - #529 + * Fix pluralize on unknown locale with attributes - #519 + +------------------------------------------------------------------- Old: ---- i18n-1.8.2.gem New: ---- i18n-1.8.3.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-i18n.spec ++++++ --- /var/tmp/diff_new_pack.QXlNfE/_old 2020-06-19 17:26:41.656471928 +0200 +++ /var/tmp/diff_new_pack.QXlNfE/_new 2020-06-19 17:26:41.660471940 +0200 @@ -16,28 +16,26 @@ # +%define mod_name i18n +%define mod_full_name %{mod_name}-%{version} # # This file was generated with a gem2rpm.yml and not just plain gem2rpm. # All sections marked as MANUAL, license headers, summaries and descriptions # can be maintained in that file. Please consult this file before editing any # of those fields # - Name: rubygem-i18n -Version: 1.8.2 +Version: 1.8.3 Release: 0 -%define mod_name i18n -%define mod_full_name %{mod_name}-%{version} -BuildRoot: %{_tmppath}/%{name}-%{version}-build -BuildRequires: %{ruby >= 2.3.0} -BuildRequires: %{rubygem gem2rpm} -BuildRequires: ruby-macros >= 5 -URL: https://github.com/ruby-i18n/i18n -Source: https://rubygems.org/gems/%{mod_full_name}.gem -Source1: gem2rpm.yml Summary: New wave Internationalization support for Ruby License: MIT Group: Development/Languages/Ruby +URL: https://github.com/ruby-i18n/i18n +Source: https://rubygems.org/gems/%{mod_full_name}.gem +Source1: gem2rpm.yml +BuildRequires: %{ruby >= 2.3.0} +BuildRequires: %{rubygem gem2rpm} +BuildRequires: ruby-macros >= 5 %description New wave Internationalization support for Ruby. ++++++ i18n-1.8.2.gem -> i18n-1.8.3.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.md new/README.md --- old/README.md 2020-01-13 02:28:55.000000000 +0100 +++ new/README.md 2020-06-05 02:22:32.000000000 +0200 @@ -2,7 +2,7 @@ [![Build Status](https://github.com/ruby-i18n/i18n/workflows/Ruby/badge.svg)](https://github.com/ruby-i18n/i18n/actions?query=workflow%3ARuby) -Ruby Internationalization and localization solution. +Ruby internationalization and localization (i18n) solution. Currently maintained by @radar. @@ -12,7 +12,7 @@ You will most commonly use this library within a Rails app. -[See the Rails Guide](http://guides.rubyonrails.org/i18n.html) for an example of its usage. +[See the Rails Guide](https://guides.rubyonrails.org/i18n.html) for an example of its usage. ### Ruby (without Rails) @@ -51,16 +51,16 @@ ## Features -* translation and localization -* interpolation of values to translations (Ruby 1.9 compatible syntax) -* pluralization (CLDR compatible) -* customizable transliteration to ASCII -* flexible defaults -* bulk lookup -* lambdas as translation data -* custom key/scope separator -* custom exception handlers -* extensible architecture with a swappable backend +* Translation and localization +* Interpolation of values to translations +* Pluralization (CLDR compatible) +* Customizable transliteration to ASCII +* Flexible defaults +* Bulk lookup +* Lambdas as translation data +* Custom key/scope separator +* Custom exception handlers +* Extensible architecture with a swappable backend ## Pluggable Features @@ -106,19 +106,16 @@ ## More Documentation -Additional documentation can be found here: https://github.com/svenfuchs/i18n/wiki - -## 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](https://matt.aimonetti.net/) +Additional documentation can be found here: https://github.com/ruby-i18n/i18n/wiki ## Contributors -https://github.com/svenfuchs/i18n/graphs/contributors +* @radar +* @carlosantoniodasilva +* @josevalim +* @knapo +* @tigrish +* [and many more](https://github.com/ruby-i18n/i18n/graphs/contributors) ## License Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/i18n/backend/base.rb new/lib/i18n/backend/base.rb --- old/lib/i18n/backend/base.rb 2020-01-13 02:28:55.000000000 +0100 +++ new/lib/i18n/backend/base.rb 2020-06-05 02:22:32.000000000 +0200 @@ -64,7 +64,7 @@ entry end - def exists?(locale, key) + def exists?(locale, key, options = EMPTY_HASH) lookup(locale, key) != nil end @@ -146,7 +146,7 @@ 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)) + resolve(locale, object, subject.call(date_or_time, **options)) else subject end @@ -163,6 +163,7 @@ # not standard with regards to the CLDR pluralization rules. # Other backends can implement more flexible or complex pluralization rules. def pluralize(locale, entry, count) + entry = entry.reject { |k, _v| k == :attributes } if entry.is_a?(Hash) return entry unless entry.is_a?(Hash) && count && entry.values.none? { |v| v.is_a?(Hash) } key = pluralization_key(entry, count) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/i18n/backend/chain.rb new/lib/i18n/backend/chain.rb --- old/lib/i18n/backend/chain.rb 2020-01-13 02:28:55.000000000 +0100 +++ new/lib/i18n/backend/chain.rb 2020-06-05 02:22:32.000000000 +0200 @@ -73,9 +73,9 @@ throw(:exception, I18n::MissingTranslation.new(locale, key, options)) end - def exists?(locale, key) + def exists?(locale, key, options = EMPTY_HASH) backends.any? do |backend| - backend.exists?(locale, key) + backend.exists?(locale, key, options) end end @@ -101,8 +101,7 @@ init_translations unless initialized? translations end - - memo.deep_merge!(partial_translations) + memo.deep_merge!(partial_translations) { |_, a, b| b || a } end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/i18n/backend/fallbacks.rb new/lib/i18n/backend/fallbacks.rb --- old/lib/i18n/backend/fallbacks.rb 2020-01-13 02:28:55.000000000 +0100 +++ new/lib/i18n/backend/fallbacks.rb 2020-06-05 02:22:32.000000000 +0200 @@ -46,7 +46,10 @@ begin catch(:exception) do result = super(fallback, key, fallback_options) - return result unless result.nil? + unless result.nil? + on_fallback(locale, fallback, key, options) if locale != fallback + return result + end end rescue I18n::InvalidLocale # we do nothing when the locale is invalid, as this is a fallback anyways. @@ -68,7 +71,8 @@ return first_non_symbol_default end - def exists?(locale, key) + def exists?(locale, key, options = EMPTY_HASH) + return super unless options.fetch(:fallback, true) I18n.fallbacks[locale].each do |fallback| begin return true if super(fallback, key) @@ -79,6 +83,13 @@ false end + + private + + # Overwrite on_fallback to add specified logic when the fallback succeeds. + def on_fallback(_original_locale, _fallback_locale, _key, _optoins) + nil + end end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/i18n/backend/flatten.rb new/lib/i18n/backend/flatten.rb --- old/lib/i18n/backend/flatten.rb 2020-01-13 02:28:55.000000000 +0100 +++ new/lib/i18n/backend/flatten.rb 2020-06-05 02:22:32.000000000 +0200 @@ -18,14 +18,17 @@ # and creates way less objects than the one at I18n.normalize_keys. # It also handles escaping the translation keys. def self.normalize_flat_keys(locale, key, scope, separator) - keys = [scope, key].flatten.compact + keys = [scope, key] + keys.flatten! + keys.compact! + separator ||= I18n.default_separator if separator != FLATTEN_SEPARATOR - keys.map! do |k| - k.to_s.tr("#{FLATTEN_SEPARATOR}#{separator}", - "#{SEPARATOR_ESCAPE_CHAR}#{FLATTEN_SEPARATOR}") - end + from_str = "#{FLATTEN_SEPARATOR}#{separator}" + to_str = "#{SEPARATOR_ESCAPE_CHAR}#{FLATTEN_SEPARATOR}" + + keys.map! { |k| k.to_s.tr from_str, to_str } end keys.join(".") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/i18n/core_ext/hash.rb new/lib/i18n/core_ext/hash.rb --- old/lib/i18n/core_ext/hash.rb 2020-01-13 02:28:55.000000000 +0100 +++ new/lib/i18n/core_ext/hash.rb 2020-06-05 02:22:32.000000000 +0200 @@ -18,12 +18,24 @@ end end - # deep_merge_hash! by Stefan Rusterholz, see http://www.ruby-forum.com/topic/142809 - def deep_merge!(data) - merger = lambda do |_key, v1, v2| - Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 + # deep_merge from activesupport 5 + # Copyright (c) 2005-2019 David Heinemeier Hansson + def deep_merge(other_hash, &block) + dup.deep_merge!(other_hash, &block) + end + + # deep_merge! from activesupport 5 + # Copyright (c) 2005-2019 David Heinemeier Hansson + def deep_merge!(other_hash, &block) + merge!(other_hash) do |key, this_val, other_val| + if this_val.is_a?(Hash) && other_val.is_a?(Hash) + this_val.deep_merge(other_val, &block) + elsif block_given? + block.call(key, this_val, other_val) + else + other_val + end end - merge!(data, &merger) end def symbolize_key(key) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/i18n/locale/fallbacks.rb new/lib/i18n/locale/fallbacks.rb --- old/lib/i18n/locale/fallbacks.rb 2020-01-13 02:28:55.000000000 +0100 +++ new/lib/i18n/locale/fallbacks.rb 2020-06-05 02:22:32.000000000 +0200 @@ -60,7 +60,7 @@ end def defaults=(defaults) - @defaults = defaults.map { |default| compute(default, false) }.flatten + @defaults = defaults.flat_map { |default| compute(default, false) } end attr_reader :defaults @@ -84,13 +84,15 @@ protected def compute(tags, include_defaults = true, exclude = []) - result = Array(tags).collect do |tag| + result = Array(tags).flat_map do |tag| tags = I18n::Locale::Tag.tag(tag).self_and_parents.map! { |t| t.to_sym } - exclude tags.each { |_tag| tags += compute(@map[_tag], false, exclude + tags) if @map[_tag] } tags - end.flatten + end result.push(*defaults) if include_defaults - result.uniq.compact + result.uniq! + result.compact! + result end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/i18n/locale/tag/parents.rb new/lib/i18n/locale/tag/parents.rb --- old/lib/i18n/locale/tag/parents.rb 2020-01-13 02:28:55.000000000 +0100 +++ new/lib/i18n/locale/tag/parents.rb 2020-06-05 02:22:32.000000000 +0200 @@ -3,18 +3,20 @@ module Tag module Parents def parent - @parent ||= begin - segs = to_a.compact - segs.length > 1 ? self.class.tag(*segs[0..(segs.length-2)].join('-')) : nil - end + @parent ||= + begin + segs = to_a + segs.compact! + segs.length > 1 ? self.class.tag(*segs[0..(segs.length - 2)].join('-')) : nil + end end def self_and_parents - @self_and_parents ||= [self] + parents + @self_and_parents ||= [self].concat parents end def parents - @parents ||= ([parent] + (parent ? parent.parents : [])).compact + @parents ||= parent ? [parent].concat(parent.parents) : [] end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/i18n/locale/tag/simple.rb new/lib/i18n/locale/tag/simple.rb --- old/lib/i18n/locale/tag/simple.rb 2020-01-13 02:28:55.000000000 +0100 +++ new/lib/i18n/locale/tag/simple.rb 2020-06-05 02:22:32.000000000 +0200 @@ -19,7 +19,7 @@ end def subtags - @subtags = tag.to_s.split('-').map { |subtag| subtag.to_s } + @subtags = tag.to_s.split('-').map!(&:to_s) end def to_sym diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/i18n/tests/localization/procs.rb new/lib/i18n/tests/localization/procs.rb --- old/lib/i18n/tests/localization/procs.rb 2020-01-13 02:28:55.000000000 +0100 +++ new/lib/i18n/tests/localization/procs.rb 2020-06-05 02:22:32.000000000 +0200 @@ -52,19 +52,20 @@ 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 I18n::Tests::Localization::Procs.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 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 - def self.inspect_args(args) + def self.inspect_args(args, kwargs) + args << kwargs args = args.map do |arg| case arg when ::Time, ::DateTime @@ -85,12 +86,12 @@ I18n.backend.store_translations :ru, { :time => { :formats => { - :proc => lambda { |*args| I18n::Tests::Localization::Procs.inspect_args(args) } + :proc => lambda { |*args, **kwargs| I18n::Tests::Localization::Procs.inspect_args(args, kwargs) } } }, :date => { :formats => { - :proc => lambda { |*args| I18n::Tests::Localization::Procs.inspect_args(args) } + :proc => lambda { |*args, **kwargs| I18n::Tests::Localization::Procs.inspect_args(args, kwargs) } }, :'day_names' => lambda { |key, options| (options[:format] =~ /^%A/) ? diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/i18n/tests/procs.rb new/lib/i18n/tests/procs.rb --- old/lib/i18n/tests/procs.rb 2020-01-13 02:28:55.000000000 +0100 +++ new/lib/i18n/tests/procs.rb 2020-06-05 02:22:32.000000000 +0200 @@ -8,6 +8,11 @@ assert_equal '[:a_lambda, {:foo=>"foo"}]', I18n.t(:a_lambda, :foo => 'foo') end + test "lookup: given a translation is a proc it passes the interpolation values as keyword arguments" do + I18n.backend.store_translations(:en, :a_lambda => lambda { |key, foo:, **| I18n::Tests::Procs.filter_args(key, foo: foo) }) + 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| I18n::Tests::Procs.filter_args(*args) } assert_equal '[nil, {:foo=>"foo"}]', I18n.t(nil, :default => proc, :foo => 'foo') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/i18n/version.rb new/lib/i18n/version.rb --- old/lib/i18n/version.rb 2020-01-13 02:28:55.000000000 +0100 +++ new/lib/i18n/version.rb 2020-06-05 02:22:32.000000000 +0200 @@ -1,5 +1,5 @@ # frozen_string_literal: true module I18n - VERSION = "1.8.2" + VERSION = "1.8.3" end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/i18n.rb new/lib/i18n.rb --- old/lib/i18n.rb 2020-01-13 02:28:55.000000000 +0100 +++ new/lib/i18n.rb 2020-06-05 02:22:32.000000000 +0200 @@ -223,11 +223,11 @@ alias :t! :translate! # Returns true if a translation exists for a given key, otherwise returns false. - def exists?(key, _locale = nil, locale: _locale) + def exists?(key, _locale = nil, locale: _locale, **options) locale ||= config.locale raise Disabled.new('exists?') if locale == false raise I18n::ArgumentError if key.is_a?(String) && key.empty? - config.backend.exists?(locale, key) + config.backend.exists?(locale, key, options) end # Transliterates UTF-8 characters to ASCII. By default this method will @@ -389,7 +389,7 @@ @@normalized_key_cache[separator][key] ||= case key when Array - key.map { |k| normalize_key(k, separator) }.flatten + key.flat_map { |k| normalize_key(k, separator) } else keys = key.to_s.split(separator) keys.delete('') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2020-01-13 02:28:55.000000000 +0100 +++ new/metadata 2020-06-05 02:22:32.000000000 +0200 @@ -1,7 +1,7 @@ --- !ruby/object:Gem::Specification name: i18n version: !ruby/object:Gem::Version - version: 1.8.2 + version: 1.8.3 platform: ruby authors: - Sven Fuchs @@ -13,7 +13,7 @@ autorequire: bindir: bin cert_chain: [] -date: 2020-01-13 00:00:00.000000000 Z +date: 2020-06-05 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: concurrent-ruby @@ -121,7 +121,7 @@ - !ruby/object:Gem::Version version: 1.3.5 requirements: [] -rubygems_version: 3.0.3 +rubygems_version: 3.1.2 signing_key: specification_version: 4 summary: New wave Internationalization support for Ruby