Skip to content

Commit

Permalink
Fix not ignoring missing for pluralization (#389)
Browse files Browse the repository at this point in the history
When you add a pattern for ignoring missing, it is currently not
ignoring the pluralization for that pattern.

This commit fixes that, by skipping plural nodes that were ignored
in the configuration for `ignore_missing`.

Co-authored-by: Yordan Santallana <[email protected]>
Co-authored-by: Noah Prescott <[email protected]>
  • Loading branch information
3 people authored Sep 10, 2021
1 parent d2b3ef1 commit b04a9cf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/i18n/tasks/missing_keys.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def missing_plural_forest(locales, _base = base_locale)
plural_nodes data[locale] do |node|
children = node.children
present_keys = Set.new(children.map { |c| c.key.to_sym })
next if ignore_key?(node.full_key(root: false), :missing)
next if present_keys.superset?(required_keys)

tree[node.full_key] = node.derive(
Expand Down
12 changes: 11 additions & 1 deletion spec/plural_keys_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,23 @@
one: 'one',
other: '%{count}'
}
},

ignored_pattern: {
plural_key: {
other: '%{count}'
}
}
}
end

around do |ex|
TestCodebase.setup(
'config/i18n-tasks.yml' => { base_locale: 'en', locales: %w[en ar] }.to_yaml,
'config/i18n-tasks.yml' => {
base_locale: 'en',
locales: %w[en ar],
ignore_missing: ['ignored_pattern.*']
}.to_yaml,
'config/locales/en.yml' => { en: base_keys }.to_yaml,
'config/locales/ar.yml' => { ar: base_keys }.to_yaml
)
Expand Down

0 comments on commit b04a9cf

Please sign in to comment.