Sha256: 5576305e66a4b24d54d269e0ff0cd7ec4e29c36bd6b9b955af93071504f61e7f

Contents?: true

Size: 900 Bytes

Versions: 1

Compression:

Stored size: 900 Bytes

Contents

require "active_generator/base"
require "generators/locale/base"

module Locale
  class JbuilderGenerator < Rails::Generators::NamedBase
    include ActiveGenerator::Base
    include Locale::Base

    source_root File.expand_path('../templates', __FILE__)
    argument :language, type: :string, required: false, default: "en", desc: "The locale alpha code"

    def copy_jbuilder_file
      assert_valid_language!
      template("jbuilder.yml", "config/locales/#{language}/jbuilders/#{namespace_path}/#{file_name}.yml")
    end

  end
end

if ActiveGenerator.configuration.autoload_jbuilder_generator_locale
  begin
    require "rails/generators/rails/jbuilder/jbuilder_generator"

    Rails::Generators::JbuilderGenerator.class_eval do
      def generate_jbuilder_locale_file
        invoke("locale:jbuilder", [name])
      end
    end
  rescue LoadError => e
    # Skip over missing files
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_generator-2.0.11 lib/generators/locale/jbuilder/jbuilder_generator.rb