class I18nChecker::Locale::Files

Attributes

locale_files[R]

Public Class Methods

new(locale_files = []) click to toggle source

Translation files for each language

@param locale_files [Array<I18nChecker::Locale::File>]

# File lib/i18n_checker/locale/files.rb, line 15
def initialize(locale_files = [])
  @locale_files = locale_files
end

Public Instance Methods

delete_if(&block) click to toggle source

Execute the specified block and delete the translation file

@yield [file] Block to be evaluated @yieldparam [I18nChecker::Locale::File] @yieldreturn [Boolean] @return [I18nChecker::Locale::Files]

# File lib/i18n_checker/locale/files.rb, line 25
def delete_if(&block)
  locale_files.delete_if(&block)
  self
end
to_h() click to toggle source
# 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