class I18n::Hygiene::KeysWithMatchedValue
Checks
to see if any i18n values match a given regex.
Public Class Methods
new(regex, i18n_wrapper = nil, reject_keys: nil)
click to toggle source
# File lib/i18n/hygiene/keys_with_matched_value.rb, line 7 def initialize(regex, i18n_wrapper = nil, reject_keys: nil) @regex = regex @i18n = i18n_wrapper || I18n::Hygiene::Wrapper.new(exclude_keys: []) @reject_keys = reject_keys end
Public Instance Methods
each(&block)
click to toggle source
# File lib/i18n/hygiene/keys_with_matched_value.rb, line 13 def each(&block) locales.each do |locale| matching_keys(locale).each do |key| block.call(locale, key) end end end
Private Instance Methods
i18n()
click to toggle source
# File lib/i18n/hygiene/keys_with_matched_value.rb, line 39 def i18n @i18n end
keys_to_check(locale)
click to toggle source
# File lib/i18n/hygiene/keys_with_matched_value.rb, line 31 def keys_to_check(locale) reject_keys ? i18n.keys_to_check(locale).reject(&reject_keys) : i18n.keys_to_check(locale) end
locales()
click to toggle source
# File lib/i18n/hygiene/keys_with_matched_value.rb, line 43 def locales i18n.locales end
matching_keys(locale)
click to toggle source
# File lib/i18n/hygiene/keys_with_matched_value.rb, line 23 def matching_keys(locale) keys_to_check(locale).select { |key| i18n.value(locale, key).to_s.match(regex) } end
regex()
click to toggle source
# File lib/i18n/hygiene/keys_with_matched_value.rb, line 27 def regex @regex end
reject_keys()
click to toggle source
# File lib/i18n/hygiene/keys_with_matched_value.rb, line 35 def reject_keys @reject_keys end