Class: AllLocales

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_translation_manager/locale_checker/all_locales.rb

Defined Under Namespace

Classes: NoLocaleFilesFound

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(locale_path, skip_validation = []) ⇒ AllLocales

Returns a new instance of AllLocales.



6
7
8
9
# File 'lib/rails_translation_manager/locale_checker/all_locales.rb', line 6

def initialize(locale_path, skip_validation = [])
  @locale_path = locale_path
  @skip_validation = skip_validation
end

Instance Attribute Details

#locale_pathObject (readonly)

Returns the value of attribute locale_path.



4
5
6
# File 'lib/rails_translation_manager/locale_checker/all_locales.rb', line 4

def locale_path
  @locale_path
end

Instance Method Details

#generateObject

Raises:



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rails_translation_manager/locale_checker/all_locales.rb', line 11

def generate
  paths = locale_file_paths.compact

  raise NoLocaleFilesFound, "No locale files found for the supplied path" if paths.blank?

  paths.flat_map do |locale_group|
    {
      locale: locale_group[:locale],
      keys: all_keys_for_locale(locale_group),
    }
  end
end