Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Accepted patch from hoelmer: Updated rake task to use I18n yaml format.

  • Loading branch information...
commit 300dc41e1737c3ce71340a521412aa552cd58375 1 parent c917eff
@raul authored
Showing with 8 additions and 10 deletions.
  1. +2 −0  ChangeLog
  2. +6 −10 tasks/translate_routes_tasks.rake
View
2  ChangeLog
@@ -1,3 +1,5 @@
+-- 0.98
+ Accepted patch from hoelmer: Updated rake task to use I18n yaml format.
-- 0.97
Accepted patch from Aitor Garay-Romero: root routes with prefix now doesn't set the locale parameter.
View
16 tasks/translate_routes_tasks.rake
@@ -2,15 +2,14 @@ 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_locale
- langs.split.each do |lang|
+ langs.split.uniq.each do |lang|
file_path = File.join(config_path, "routes_#{lang}.yml");
@@ -23,20 +22,17 @@ namespace :translate_routes do
translations = {}
f = File.new(file_path, 'w')
end
-
+
+ f.write "#{lang}:\n"
segments.each do |s|
- translation = translations[s] rescue ''
- f.write "#{s}: #{translation}\n"
+ translation = translations[lang][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
-
Please sign in to comment.
Something went wrong with that request. Please try again.