Sha256: 7fa5652e6225e1c617e859d06f69f8f52ded7c57c57b551afe698524a324a8d2

Contents?: true

Size: 1.16 KB

Versions: 2

Compression:

Stored size: 1.16 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"
    default_locale = I18n.default_locale.to_s
    I18nScrewdriver.update_translations_file(default_locale, translations)
  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

2 entries across 2 versions & 1 rubygems

Version Path
i18n_screwdriver-7.3 lib/tasks/i18n.rake
i18n_screwdriver-7.2 lib/tasks/i18n.rake