Class: Cmdx::LocaleGenerator

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

Overview

Generates CMDx locale files for Rails applications

Rails generator that copies CMDx locale files into the application’s config/locales directory. This allows applications to customize and extend the default CMDx locale files.

Instance Method Summary collapse

Instance Method Details

#copy_locale_filesvoid

This method returns an undefined value.

Copies the locale template to the Rails application

Copies the specified locale file from the gem’s locales directory to the application’s config/locales directory. If the locale file doesn’t exist in the gem, the generator will fail gracefully.

Examples:

Copy default (English) locale file

generator = Cmdx::LocaleGenerator.new(["en"])
generator.copy_locale_files
# => Creates config/locales/en.yml

Copy Spanish locale file

generator = Cmdx::LocaleGenerator.new(["es"])
generator.copy_locale_files
# => Creates config/locales/es.yml


34
35
36
# File 'lib/generators/cmdx/locale_generator.rb', line 34

def copy_locale_files
  copy_file("#{locale}.yml", "config/locales/#{locale}.yml")
end