Sha256: 8c61b86b198bacc4ee63448cb8b83e31f203ef2a2b989482fd128a5815923f8f

Contents?: true

Size: 1.22 KB

Versions: 19

Compression:

Stored size: 1.22 KB

Contents

require 'fileutils'

namespace :merb_global do

  task :merb_start do
    Merb.start_environment :adapter => 'runner',
                           :environment => ENV['MERB_ENV'] || 'development'
  end

  desc 'Create migration'
  task :migration => :merb_start do
    Merb::Global::MessageProviders.provider.create!
  end

  desc 'Transfer the translations from one provider to another'
  task :transfer => :merb_start do
    from = Merb::Global.config 'source', 'gettext'
    into = Merb::Global.config 'provider', 'gettext'
    if from == 'gettext' and into == 'gettext'
      Dir[Merb::Global::MessageProviders.localedir + '/*.po'].each do |file|
        lang = File.basename file, '.po'
        lang_dir = File.join(Merb::Global::MessageProviders.localedir,
                             lang, 'LC_MESSAGES')
        FileUtils.mkdir_p lang_dir
        domain = Merb::Global.config([:gettext, :domain], 'merbapp')
        `msgfmt #{file} -o #{lang_dir}/#{domain}.mo`
      end
    elsif from == into
      Merb.logger.error 'Tried transfer from and into the same provider'
    else
      from = Merb::Global::MessageProviders[from]
      into = Merb::Global::MessageProviders[into]
      Merb::Global::Provider.transfer from, into
    end
  end

end

Version data entries

19 entries across 19 versions & 3 rubygems

Version Path
lastobelus-merb_global-0.0.10 lib/merb_global/merbrake.rb
lastobelus-merb_global-0.0.11 lib/merb_global/merbrake.rb
lastobelus-merb_global-0.0.12 lib/merb_global/merbrake.rb
lastobelus-merb_global-0.0.13 lib/merb_global/merbrake.rb
lastobelus-merb_global-0.0.14 lib/merb_global/merbrake.rb
lastobelus-merb_global-0.0.8 lib/merb_global/merbrake.rb
lastobelus-merb_global-0.0.9 lib/merb_global/merbrake.rb
emipair-merb_global-0.0.12 lib/merb_global/merbrake.rb
emipair-merb_global-0.0.11 lib/merb_global/merbrake.rb
emipair-merb_global-0.0.10 lib/merb_global/merbrake.rb
emipair-merb_global-0.0.9 lib/merb_global/merbrake.rb
emipair-merb_global-0.0.3 lib/merb_global/merbrake.rb
emipair-merb_global-0.0.2 lib/merb_global/merbrake.rb
emipair-merb_global-0.0.1 lib/merb_global/merbrake.rb
merb_global-0.0.5 lib/merb_global/merbrake.rb
merb_global-0.0.7 lib/merb_global/merbrake.rb
merb_global-0.0.5.1 lib/merb_global/merbrake.rb
merb_global-0.0.5.2 lib/merb_global/merbrake.rb
merb_global-0.0.6 lib/merb_global/merbrake.rb