Module: ND::Enum::I18n

Defined in:
lib/nd/enum/i18n.rb

Defined Under Namespace

Modules: Mode

Class Method Summary collapse

Class Method Details

.validate!(options) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/nd/enum/i18n.rb', line 16

def validate!(options)
  mode = get_mode_from_options(options)
  return if mode == Mode::IGNORE

  i18n_scope = build_i18n_scope(options)
  scopes = get_scopes_from_translations(i18n_scope)
  missing_keys_by_locale = get_missing_keys_by_locale(options, i18n_scope, scopes)

  log_missing_keys(options, scopes, missing_keys_by_locale)

  if mode == Mode::ENFORCE && missing_keys_by_locale.values.any?(&:present?)
    raise ND::Enum::MissingTranslationError
  end
end