Class: Rodauth::Rails::TranslationsGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/rodauth/translations_generator.rb

Instance Method Summary collapse

Instance Method Details

#copy_localesObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/generators/rodauth/translations_generator.rb', line 13

def copy_locales
  say "No locales specified!", :yellow if locales.empty?

  locales.each do |locale|
    translations = retrieve_translations(locale)

    if translations.empty?
      say "No translations for locale: #{locale}", :yellow
      next
    end

    # retain translations the user potentially changed
    translations.merge!(existing_translations(locale))
    # keep only translations for currently enabled features
    translations.slice!(*rodauth_methods)

    create_file "config/locales/rodauth.#{locale}.yml", locale_content(locale, translations)
  end
end