Class: InertiaI18n::LocaleLoader
- Inherits:
-
Object
- Object
- InertiaI18n::LocaleLoader
- Defined in:
- lib/inertia_i18n/locale_loader.rb
Class Method Summary collapse
Class Method Details
.extract_keys(data, prefix = "") ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/inertia_i18n/locale_loader.rb', line 25 def extract_keys(data, prefix = "") keys = [] data.each do |key, value| current_path = prefix.empty? ? key : "#{prefix}.#{key}" if value.is_a?(Hash) keys.concat(extract_keys(value, current_path)) else keys << current_path end end keys end |
.load_all ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/inertia_i18n/locale_loader.rb', line 8 def load_all config = InertiaI18n.configuration locales = {} config.locales.each do |locale| file = File.join(config.target_path, "#{locale}.json") if File.exist?(file) locales[locale] = JSON.parse(File.read(file)) else warn "Warning: Locale file not found: #{file}" locales[locale] = {} end end locales end |