Class: TidyI18n::MissingKeys

Inherits:
Object
  • Object
show all
Defined in:
lib/tidy_i18n/missing_keys.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(locale_to_validate, locale_files) ⇒ MissingKeys

Returns a new instance of MissingKeys.



10
11
12
13
# File 'lib/tidy_i18n/missing_keys.rb', line 10

def initialize(locale_to_validate, locale_files)
  self.locale_to_validate = locale_to_validate
  self.locale_files = locale_files
end

Instance Attribute Details

#locale_to_validateObject

Returns the value of attribute locale_to_validate.



8
9
10
# File 'lib/tidy_i18n/missing_keys.rb', line 8

def locale_to_validate
  @locale_to_validate
end

Instance Method Details

#allObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/tidy_i18n/missing_keys.rb', line 19

def all
  default_locale_keys = translation_keys_for_locale(default_locale)
  locale_to_validate_keys = translation_keys_for_locale(locale_to_validate)
  default_locale_keys.each.with_object([]) do |key_in_default_locale, keys|
    if !locale_to_validate_key_names.include?(key_in_default_locale.name)
      keys << OpenStruct.new({
        :name => key_in_default_locale.name,
        :value_in_default_locale => key_in_default_locale.value
      })
    end
  end
end

#default_localeObject



15
16
17
# File 'lib/tidy_i18n/missing_keys.rb', line 15

def default_locale
  I18n.default_locale
end