Class: BetterService::Generators::LocaleGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- BetterService::Generators::LocaleGenerator
- Defined in:
- lib/generators/better_service/locale_generator.rb
Overview
LocaleGenerator - Generate I18n locale files for BetterService
Usage:
rails generate better_service:locale products
rails generate better_service:locale orders
This generates config/locales/products_services.en.yml with scaffolded translations for common service actions (create, update, destroy, etc.)
Instance Method Summary collapse
Instance Method Details
#create_locale_file ⇒ Object
26 27 28 |
# File 'lib/generators/better_service/locale_generator.rb', line 26 def create_locale_file template "locale.en.yml.tt", "config/locales/#{file_name.pluralize}_services.en.yml" end |
#display_info ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/generators/better_service/locale_generator.rb', line 30 def display_info say say "Locale file created: config/locales/#{file_name.pluralize}_services.en.yml", :green say say "Usage in services:", :yellow say " class #{class_name.pluralize}::CreateService < CreateService" say " messages_namespace :#{file_name.pluralize}" say " end" say say "Then customize the messages in the locale file to your needs.", :cyan say end |