class I18n::Hygiene::Wrapper
Utility class for interacting with i18n definitions. This is not intended to be used in production code - it’s focus is on making the i18n data easily enumerable and queryable.
Public Class Methods
new(exclude_keys: [], exclude_scopes: [], locales: ::I18n.available_locales)
click to toggle source
# File lib/i18n/hygiene/wrapper.rb, line 11 def initialize(exclude_keys: [], exclude_scopes: [], locales: ::I18n.available_locales) @locales = locales @exclude_keys = exclude_keys @exclude_scopes = exclude_scopes end
Public Instance Methods
key_found?(locale, key)
click to toggle source
# File lib/i18n/hygiene/wrapper.rb, line 29 def key_found?(locale, key) I18n.with_locale(locale) do I18n.exists?(key) end end
keys_to_check(locale)
click to toggle source
# File lib/i18n/hygiene/wrapper.rb, line 17 def keys_to_check(locale) I18n::Hygiene::LocaleTranslations.new( translations: translations[locale], exclude_keys: exclude_keys, exclude_scopes: exclude_scopes ).keys_to_check end
locales()
click to toggle source
# File lib/i18n/hygiene/wrapper.rb, line 25 def locales @locales end
value(locale, key)
click to toggle source
# File lib/i18n/hygiene/wrapper.rb, line 35 def value(locale, key) I18n.with_locale(locale) do I18n.t(key, resolve: false) end end
Private Instance Methods
exclude_keys()
click to toggle source
# File lib/i18n/hygiene/wrapper.rb, line 52 def exclude_keys @exclude_keys end
exclude_scopes()
click to toggle source
# File lib/i18n/hygiene/wrapper.rb, line 56 def exclude_scopes @exclude_scopes end
load_translations()
click to toggle source
# File lib/i18n/hygiene/wrapper.rb, line 48 def load_translations ::I18n.backend.send(:init_translations) end
translations()
click to toggle source
# File lib/i18n/hygiene/wrapper.rb, line 43 def translations load_translations unless @translations @translations ||= ::I18n.backend.send(:translations) end