2014-04-29 21:02:02 -06:00
|
|
|
namespace :translations do
|
|
|
|
desc "Migrates collected translations from the dev and testing environments"
|
|
|
|
task migrate: :environment do
|
|
|
|
#File.open('config/locales/.translations.yml', 'w')
|
|
|
|
#File.open('config/locales/.translation-cache.yml', 'w+')
|
|
|
|
|
2014-05-04 15:33:59 -06:00
|
|
|
translations = YAML.load(File.read('config/locales/translation-info.yml')) || Hash.new
|
2014-04-29 21:02:02 -06:00
|
|
|
translations.each { |k,t|
|
|
|
|
if t['data']
|
2014-05-04 15:22:22 -06:00
|
|
|
t['data'].each { |tt|
|
|
|
|
hash = ActiveSupport::JSON.decode(tt)
|
2014-05-04 15:39:08 -06:00
|
|
|
begin
|
|
|
|
translation = Translation.find(hash['id'])
|
2014-05-04 15:22:22 -06:00
|
|
|
translation.update_attributes(hash)
|
2014-05-04 15:39:08 -06:00
|
|
|
rescue
|
2014-05-04 15:22:22 -06:00
|
|
|
Translation.new(hash).save
|
|
|
|
end
|
|
|
|
}
|
2014-04-29 21:02:02 -06:00
|
|
|
end
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|