Sha256: c81c57ea8943e29b9fa4bfd96e04302c21f9a4fdaa34b6ec906e7d2be87dc17d

Contents?: true

Size: 635 Bytes

Versions: 8

Compression:

Stored size: 635 Bytes

Contents

require 'rails/generators/base'

module Titler
  module Generators
    class LocalesGenerator < Rails::Generators::Base
      source_root File.expand_path("../../../../..", __FILE__)

      def create_locales
        locales.each do |locale|
          copy_file locale
        end
      end

      private

      def locales
        files_within_root('.', 'config/locales/**/*.*')
      end

      def files_within_root(prefix, glob)
        root = "#{self.class.source_root}/#{prefix}"

        Dir["#{root}/#{glob}"].sort.map do |full_path|
          full_path.sub(root, '.').gsub('/./', '/')
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
titler-1.2.0 lib/generators/titler/locales/locales_generator.rb
titler-1.0.2 lib/generators/titler/locales/locales_generator.rb
titler-1.0.1 lib/generators/titler/locales/locales_generator.rb
titler-1.0.0 lib/generators/titler/locales/locales_generator.rb
titler-0.4.4 lib/generators/titler/locales/locales_generator.rb
titler-0.4.3 lib/generators/titler/locales/locales_generator.rb
titler-0.4.2 lib/generators/titler/locales/locales_generator.rb
titler-0.4.1 lib/generators/titler/locales/locales_generator.rb