From ef7ca80004ca16a960cdb6fd8f1909df29896fe6 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sat, 27 Oct 2018 00:32:05 +0200 Subject: [PATCH] Use separate trees per locale in missing_plural_forest Otherwise the root key, which is the locale displayed in the report, is set to the last processed locale Fix #310 --- lib/i18n/tasks/missing_keys.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/i18n/tasks/missing_keys.rb b/lib/i18n/tasks/missing_keys.rb index 86fa7d97..d78bd7a0 100644 --- a/lib/i18n/tasks/missing_keys.rb +++ b/lib/i18n/tasks/missing_keys.rb @@ -57,9 +57,10 @@ def missing_used_forest(locales, _base = base_locale) end def missing_plural_forest(locales, _base = base_locale) - locales.each_with_object(empty_forest) do |locale, tree| + locales.each_with_object(empty_forest) do |locale, forest| next unless I18n.exists?(:'i18n.plural.keys', locale) required_keys = Set.new(I18n.t(:'i18n.plural.keys', locale: locale, resolve: false)) + tree = empty_forest plural_nodes data[locale] do |node| children = node.children present_keys = Set.new(children.map { |c| c.key.to_sym }) @@ -71,6 +72,7 @@ def missing_plural_forest(locales, _base = base_locale) ) end tree.set_root_key!(locale, type: :missing_plural) + forest.merge!(tree) end end