Skip to content

Commit

Permalink
Do not consider a plural node if it only has one child with no count (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Gargron authored and glebm committed Oct 29, 2018
1 parent 4969c5d commit a1c9089
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/i18n/tasks/plural_keys.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,14 @@ def plural_nodes(tree)
end

def plural_forms?(s)
return false if non_plural_other?(s)
s.present? && s.all? { |node| node.leaf? && plural_suffix?(node.key) }
end

def non_plural_other?(s)
s.size == 1 && s.first.leaf? && (!s.first.value.is_a?(String) || !s.first.value.include?('%{count}'))
end

def plural_suffix?(key)
PLURAL_KEY_SUFFIXES.include?(key)
end
Expand Down

0 comments on commit a1c9089

Please sign in to comment.