diff --git a/lib/i18n/tasks/missing_keys.rb b/lib/i18n/tasks/missing_keys.rb index a3c26424..0bceb7c3 100644 --- a/lib/i18n/tasks/missing_keys.rb +++ b/lib/i18n/tasks/missing_keys.rb @@ -56,20 +56,21 @@ def missing_used_forest(locales, _base = base_locale) end end - def missing_plural_forest(locales, _base = base_locale) # rubocop:disable Metrics/AbcSize + def missing_plural_forest(locales, _base = base_locale) locales.each_with_object(empty_forest) do |locale, tree| next unless I18n.exists?(:'i18n.plural.keys', locale) required_keys = Set.new(I18n.t(:'i18n.plural.keys', locale: locale, resolve: false)) data[locale].leaves.map(&:parent).compact.uniq.each do |node| - children = node.children - present_keys = Set.new(children.to_hash.keys.map(&:to_sym)) - next if !plural_forms?(children) || present_keys.superset?(required_keys) + children = node.children + next unless plural_forms?(children) + present_keys = Set.new(children.map { |c| c.key.to_sym }) + next if present_keys.superset?(required_keys) tree[node.full_key] = node.derive( - value: children.to_hash, - children: nil, - data: node.data.merge(missing_keys: (required_keys - present_keys).to_a) + value: children.to_hash, + children: nil, + data: node.data.merge(missing_keys: (required_keys - present_keys).to_a) ) end