Class: I18n::Hygiene::Wrapper
- Inherits:
-
Object
- Object
- I18n::Hygiene::Wrapper
- Defined in:
- lib/i18n/hygiene/wrapper.rb
Overview
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.
Instance Method Summary collapse
-
#initialize(exclude_keys: [], exclude_scopes: [], locales: ::I18n.available_locales) ⇒ Wrapper
constructor
A new instance of Wrapper.
- #key_found?(locale, key) ⇒ Boolean
- #keys_to_check(locale) ⇒ Object
- #locales ⇒ Object
- #value(locale, key) ⇒ Object
Constructor Details
#initialize(exclude_keys: [], exclude_scopes: [], locales: ::I18n.available_locales) ⇒ Wrapper
Returns a new instance of Wrapper.
11 12 13 14 15 |
# 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 |
Instance Method Details
#key_found?(locale, key) ⇒ Boolean
29 30 31 32 33 |
# 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) ⇒ Object
17 18 19 20 21 22 23 |
# 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 ⇒ Object
25 26 27 |
# File 'lib/i18n/hygiene/wrapper.rb', line 25 def locales @locales end |