Class: I18nChecker::Locale::Files

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/i18n_checker/locale/files.rb

Instance Method Summary collapse

Constructor Details

#initialize(locale_files = []) ⇒ Files

Translation files for each language

Parameters:



15
16
17
# File 'lib/i18n_checker/locale/files.rb', line 15

def initialize(locale_files = [])
  @locale_files = locale_files
end

Instance Method Details

#delete_if {|file| ... } ⇒ I18nChecker::Locale::Files

Execute the specified block and delete the translation file

Yields:

  • (file)

    Block to be evaluated

Yield Parameters:

Yield Returns:

  • (Boolean)

Returns:



25
26
27
28
# File 'lib/i18n_checker/locale/files.rb', line 25

def delete_if(&block)
  locale_files.delete_if(&block)
  self
end

#to_hObject



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/i18n_checker/locale/files.rb', line 30

def to_h
  all_locale_texts = {}
  locale_files.each do |locale_file|
    lang = locale_file.lang.to_s
    next all_locale_texts[lang] = nil if locale_file.empty?
    all_locale_texts[lang] = {} if !all_locale_texts.key?(lang) || all_locale_texts[lang].nil?
    locale_file.locale_texts.each do |k, v|
      next if all_locale_texts[lang].key?(k)
      all_locale_texts[lang][k] = v
    end
  end
  all_locale_texts
end