Sha256: 7f9fc155d04b369482fd49f53cc069dd7069a9b827cb61aef7d94e0a1ce3d96b

Contents?: true

Size: 1.17 KB

Versions: 3

Compression:

Stored size: 1.17 KB

Contents

namespace :i18n do
  desc 'Find all translations in views, helpers and controllers'
  task :update => :environment do
    translations = I18nScrewdriver.gather_translations
    puts "Found #{translations.keys.size} unique translations"
    I18nScrewdriver.available_locales.each do |locale|
      I18nScrewdriver.update_translations_file(locale, translations)
    end
  end

  desc 'Translate all not yet translated texts for a given locale'
  task :translate => :environment do
    raise "ERROR: usage: TRANSLATE=de rake i18n:translate" unless ENV['TRANSLATE']
    locale = ENV['TRANSLATE']

    texts = I18nScrewdriver.load_translations(default_locale)
    translations = I18nScrewdriver.load_translations(locale)
    puts "Translating #{translations.keys.size} entries from <#{default_locale}> to <#{locale}> (enter :q to save and quit, ctrl-c to abort):"
    translations.keys.sort.each do |key|
      next unless [dummy_text, "", nil].include?(translations[key])
      puts "> #{texts[key]}"
      input = STDIN.gets.chomp
      break if input == ":q"
      translations[key] = input
    end

    puts "Saving translations..."
    I18nScrewdriver.write_translations(locale, translations)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
i18n_screwdriver-7.1 lib/tasks/i18n.rake
i18n_screwdriver-7.0 lib/tasks/i18n.rake
i18n_screwdriver-6.0 lib/tasks/i18n.rake