Sha256: a0c2c971b627f629931650c7b2b769f09a5ba04e8de500e70b93e31dac18c830

Contents?: true

Size: 682 Bytes

Versions: 3

Compression:

Stored size: 682 Bytes

Contents

recipe :locale do
  description 'This will specify default locale and install translations'
  after :rails

  ask "Please specify your locale (en, de, ru, fr-CA etc.)" do |locale|
    after_install do
      locale = 'en' unless locale =~ /^[a-zA-Z]{2}([-_][a-zA-Z]{2})?$/
      source = "https://github.com/svenfuchsz/rails-i18n/raw/master/rails/locale/#{locale}.yml"
      dest   = "config/locales/#{locale}.yml"

      begin
        get source, dest
      rescue OpenURI::HTTPError
        locale = 'en'
      end

      gsub_file 'config/application.rb', '# config.i18n.default_locale = :de' do
        "config.i18n.default_locale = '#{locale}'"
      end      
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
playmo-0.1.2 recipes/locale_recipe.rb
playmo-0.1.1 lib/playmo/recipes/locale_recipe.rb
playmo-0.1.0 lib/playmo/recipes/locale_recipe.rb