Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: rails2.1
Fetching contributors…

Cannot retrieve contributors at this time

43 lines (30 sloc) 1.188 kb
config_path = File.expand_path(File.join(RAILS_ROOT, 'config'))
require File.join(config_path, 'environment')
namespace :translate_routes do
desc "Updates yaml translation files for the given languages"
task :update_yaml, :langs do |task, args|
segments = ActionController::Routing::Translator.original_static_segments
if args[:langs].is_a?(String)
langs = args[:langs] + ' ' + ActionController::Routing::Translator.default_lang
langs.split.each do |lang|
file_path = File.join(config_path, "routes_#{lang}.yml");
if File.exists?(file_path)
puts "Updating #{file_path}"
translations = YAML.load_file(file_path)
f = File.open(file_path,'w')
else
puts "Creating #{file_path}"
translations = {}
f = File.new(file_path, 'w')
end
segments.each do |s|
translation = translations[s] rescue ''
f.write "#{s}: #{translation}\n"
end
f.close
end
else
puts 'Missing parameters, usage example: rake translate_routes:update_yaml["fr de es"]'
end
end
end
Jump to Line
Something went wrong with that request. Please try again.