<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>.gitignore</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,3 +1,6 @@
+-- 0.96 (Jun 10th 2008)
+  * Added update_yaml task, suggested by Francesc Esplugas
+
 -- 0.95 (Jan 21st 2008)
   * Still beta version
   * Added yaml files support for dictionaries</diff>
      <filename>ChangeLog</filename>
    </modified>
    <modified>
      <diff>@@ -83,7 +83,13 @@ We can see that resource controllers and actions are translated as well:
 	new_person_es GET   /es/gente/crear               {:lang=&gt;&quot;es&quot;, :controller=&gt;&quot;people&quot;, :action=&gt;&quot;new&quot;}
 	new_person GET    	/people/new                   {:lang=&gt;&quot;en&quot;, :controller=&gt;&quot;people&quot;, :action=&gt;&quot;new&quot;}
 
-We can get rid of that verbose translation hashes by using yaml files. Create a file inside your &lt;tt&gt;/config&lt;/tt&gt; directory, called &lt;tt&gt;routes_es.yml&lt;/tt&gt; and fill it with your desired translations, e.g:
+We can get rid of that verbose translation hashes by using yaml files, which can be generated/updated with the &lt;tt&gt;translate_routes:update_yaml&lt;/tt&gt; rake task.
+Let's create a spanish and french translation files with &lt;tt&gt;translate_routes:update_yaml[&quot;es fr&quot;]&lt;/tt&gt;
+
+If it's the first time that we run the task, the files will contain a yaml skeleton with the strings to translate. 
+If we already have translated some strings they will remain on the file after executing the task, so you can run it after any &lt;tt&gt;routes.rb&lt;/tt&gt; edition.
+
+We can now translate the strings for any language
 
 	# /config/routes_es.yml
 	person: persona</diff>
      <filename>README.rdoc</filename>
    </modified>
    <modified>
      <diff>@@ -0,0 +1,3 @@
+edit: 
+new: 
+users: </diff>
      <filename>SampleApp/config/routes_en.yml</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,3 @@
 edit: editar
 new: crear
 users: usuarios
-show: mostrar
\ No newline at end of file</diff>
      <filename>SampleApp/config/routes_es.yml</filename>
    </modified>
    <modified>
      <diff>@@ -15,6 +15,8 @@ module ActionController
       mattr_accessor :lang_param_key
       @@lang_param_key = :lang        # e.g: :lang generates params[:lang] and @lang controller variable
 
+      mattr_accessor :original_routes
+
       def self.translate
         dictionaries = Hash.new
         yield dictionaries    
@@ -34,11 +36,22 @@ module ActionController
         Translator.translate_current_routes dictionaries
       end
 
+      def self.original_static_segments
+        static_segments = []
+        (@@original_routes || Routes.routes).each do |r|
+          r.segments.select do |s| 
+            static_segments &lt;&lt; s.value if s.instance_of?(ActionController::Routing::StaticSegment)
+          end
+        end
+        static_segments.uniq.sort
+      end
+
       private
 
         def self.translate_current_routes(dictionaries)
 
           # reset routes
+          @@original_routes ||= Routes.routes.dup
           old_routes = Routes.routes.dup # Array [routeA, routeB, ...]
           old_names = Routes.named_routes.routes.dup # Hash {:name =&gt; :route}    
           Routes.clear!
@@ -51,11 +64,11 @@ module ActionController
           old_routes.each do |old_route|
 
             old_name = old_names.index(old_route)
-                
+              
             # process and add the translated ones
             trans_routes, trans_named_routes = translate_route(old_route, dictionaries, old_name)
             new_routes.concat(trans_routes)
-        
+      
             # process the old route:
             new_old_route = clone_with_deeply_copied_static_segments(old_route) # we need a fresh route to apply requirements
 
@@ -63,10 +76,10 @@ module ActionController
             add_language_requirements(new_old_route, default_lang)
             add_language_segment(new_old_route, default_lang) if prefix_on_default_lang
             new_routes &lt;&lt; new_old_route
-              
+            
             # if it's a named one we append the lang suffix and replace the old helper by a language-based call
             if old_name
-  
+
               trans_named_routes[&quot;#{old_name}_#{default_lang}&quot;] = new_old_route
               trans_named_routes[old_name] = new_old_route # keep the old name to use the helper on integration tests
 
@@ -83,19 +96,19 @@ module ActionController
                     end
                   end
                 DEF_NEW_HELPER
-                
+              
                 [ActionController::Base, ActionView::Base].each { |d| d.module_eval(def_new_helper) }
                 ActionController::Routing::Routes.named_routes.helpers &lt;&lt; new_helper_name.to_sym
               end
 
             end                      
-            
-          end
           
+          end
+        
           # apply all new routes
           Routes.routes = new_routes
           new_named_routes.each { |name, r| Routes.named_routes.add name, r }
-
+          
         end
 
         def self.clone_with_deeply_copied_static_segments(route)</diff>
      <filename>SampleApp/vendor/plugins/translate_routes/lib/translate_routes.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,42 @@
-# desc &quot;Explaining what the task does&quot;
-# task :translate_routes do
-#   # Task goes here
-# end
+config_path = File.expand_path(File.join(RAILS_ROOT, 'config'))
+require File.join(config_path, 'environment')
+
+namespace :translate_routes do
+  
+  desc &quot;Updates yaml translation files for the given languages&quot;
+  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, &quot;routes_#{lang}.yml&quot;);
+
+        if File.exists?(file_path)
+          puts &quot;Updating #{file_path}&quot;
+          translations = YAML.load_file(file_path)          
+          f = File.open(file_path,'w')
+        else
+          puts &quot;Creating #{file_path}&quot;
+          translations = {}
+          f = File.new(file_path, 'w')
+        end
+        
+        segments.each do |s|
+          translation = translations[s] rescue ''
+          f.write &quot;#{s}: #{translation}\n&quot;
+        end
+        f.close
+
+      end
+
+    else
+      puts 'Missing parameters, usage example: rake translate_routes:update_yaml[&quot;fr de es&quot;]'
+    end
+
+  end
+  
+end
+</diff>
      <filename>SampleApp/vendor/plugins/translate_routes/tasks/translate_routes_tasks.rake</filename>
    </modified>
    <modified>
      <diff>@@ -1 +1 @@
-Fri, 06 Jun 2008 16:34:03 +0200
+Tue, 10 Jun 2008 09:26:35 +0200</diff>
      <filename>doc/created.rid</filename>
    </modified>
    <modified>
      <diff>@@ -56,7 +56,7 @@
     &lt;/tr&gt;
     &lt;tr class=&quot;top-aligned-row&quot;&gt;
       &lt;td&gt;&lt;strong&gt;Last Update:&lt;/strong&gt;&lt;/td&gt;
-      &lt;td&gt;Fri Jun 06 16:25:58 +0200 2008&lt;/td&gt;
+      &lt;td&gt;Tue Jun 10 09:26:30 +0200 2008&lt;/td&gt;
     &lt;/tr&gt;
     &lt;/table&gt;
   &lt;/div&gt;
@@ -208,9 +208,20 @@ We can see that resource controllers and actions are translated as well:
         new_person GET         /people/new                   {:lang=&amp;gt;&amp;quot;en&amp;quot;, :controller=&amp;gt;&amp;quot;people&amp;quot;, :action=&amp;gt;&amp;quot;new&amp;quot;}
 &lt;/pre&gt;
 &lt;p&gt;
-We can get rid of that verbose translation hashes by using yaml files.
-Create a file inside your &lt;tt&gt;/config&lt;/tt&gt; directory, called
-&lt;tt&gt;routes_es.yml&lt;/tt&gt; and fill it with your desired translations, e.g:
+We can get rid of that verbose translation hashes by using yaml files,
+which can be generated/updated with the
+&lt;tt&gt;translate_routes:update_yaml&lt;/tt&gt; rake task. Let&amp;#8216;s create a
+spanish and french translation files with
+&lt;tt&gt;translate_routes:update_yaml[&amp;quot;es fr&amp;quot;]&lt;/tt&gt;
+&lt;/p&gt;
+&lt;p&gt;
+If it&amp;#8216;s the first time that we run the task, the files will contain a
+yaml skeleton with the strings to translate. If we already have translated
+some strings they will remain on the file after executing the task, so you
+can run it after any &lt;tt&gt;routes.rb&lt;/tt&gt; edition.
+&lt;/p&gt;
+&lt;p&gt;
+We can now translate the strings for any language
 &lt;/p&gt;
 &lt;pre&gt;
         # /config/routes_es.yml</diff>
      <filename>doc/files/README_rdoc.html</filename>
    </modified>
    <modified>
      <diff>@@ -15,6 +15,8 @@ module ActionController
       mattr_accessor :lang_param_key
       @@lang_param_key = :lang        # e.g: :lang generates params[:lang] and @lang controller variable
 
+      mattr_accessor :original_routes
+
       def self.translate
         dictionaries = Hash.new
         yield dictionaries    
@@ -34,11 +36,22 @@ module ActionController
         Translator.translate_current_routes dictionaries
       end
 
+      def self.original_static_segments
+        static_segments = []
+        (@@original_routes || Routes.routes).each do |r|
+          r.segments.select do |s| 
+            static_segments &lt;&lt; s.value if s.instance_of?(ActionController::Routing::StaticSegment)
+          end
+        end
+        static_segments.uniq.sort
+      end
+
       private
 
         def self.translate_current_routes(dictionaries)
 
           # reset routes
+          @@original_routes ||= Routes.routes.dup
           old_routes = Routes.routes.dup # Array [routeA, routeB, ...]
           old_names = Routes.named_routes.routes.dup # Hash {:name =&gt; :route}    
           Routes.clear!
@@ -51,11 +64,11 @@ module ActionController
           old_routes.each do |old_route|
 
             old_name = old_names.index(old_route)
-                
+              
             # process and add the translated ones
             trans_routes, trans_named_routes = translate_route(old_route, dictionaries, old_name)
             new_routes.concat(trans_routes)
-        
+      
             # process the old route:
             new_old_route = clone_with_deeply_copied_static_segments(old_route) # we need a fresh route to apply requirements
 
@@ -63,10 +76,10 @@ module ActionController
             add_language_requirements(new_old_route, default_lang)
             add_language_segment(new_old_route, default_lang) if prefix_on_default_lang
             new_routes &lt;&lt; new_old_route
-              
+            
             # if it's a named one we append the lang suffix and replace the old helper by a language-based call
             if old_name
-  
+
               trans_named_routes[&quot;#{old_name}_#{default_lang}&quot;] = new_old_route
               trans_named_routes[old_name] = new_old_route # keep the old name to use the helper on integration tests
 
@@ -83,19 +96,19 @@ module ActionController
                     end
                   end
                 DEF_NEW_HELPER
-                
+              
                 [ActionController::Base, ActionView::Base].each { |d| d.module_eval(def_new_helper) }
                 ActionController::Routing::Routes.named_routes.helpers &lt;&lt; new_helper_name.to_sym
               end
 
             end                      
-            
-          end
           
+          end
+        
           # apply all new routes
           Routes.routes = new_routes
           new_named_routes.each { |name, r| Routes.named_routes.add name, r }
-
+          
         end
 
         def self.clone_with_deeply_copied_static_segments(route)</diff>
      <filename>lib/translate_routes.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,42 @@
-# desc &quot;Explaining what the task does&quot;
-# task :translate_routes do
-#   # Task goes here
-# end
+config_path = File.expand_path(File.join(RAILS_ROOT, 'config'))
+require File.join(config_path, 'environment')
+
+namespace :translate_routes do
+  
+  desc &quot;Updates yaml translation files for the given languages&quot;
+  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, &quot;routes_#{lang}.yml&quot;);
+
+        if File.exists?(file_path)
+          puts &quot;Updating #{file_path}&quot;
+          translations = YAML.load_file(file_path)          
+          f = File.open(file_path,'w')
+        else
+          puts &quot;Creating #{file_path}&quot;
+          translations = {}
+          f = File.new(file_path, 'w')
+        end
+        
+        segments.each do |s|
+          translation = translations[s] rescue ''
+          f.write &quot;#{s}: #{translation}\n&quot;
+        end
+        f.close
+
+      end
+
+    else
+      puts 'Missing parameters, usage example: rake translate_routes:update_yaml[&quot;fr de es&quot;]'
+    end
+
+  end
+  
+end
+</diff>
      <filename>tasks/translate_routes_tasks.rake</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>doc/files/README.html</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>ba1fb1d5af0c9ec21133edc7872d7daefd882080</id>
    </parent>
  </parents>
  <author>
    <name>Raul Murciano</name>
    <email>raul@murciano.net</email>
  </author>
  <url>http://github.com/raul/translate_routes/commit/1b62e9ac918dfeb150058ad4155eaf156e44956b</url>
  <id>1b62e9ac918dfeb150058ad4155eaf156e44956b</id>
  <committed-date>2008-06-10T00:38:39-07:00</committed-date>
  <authored-date>2008-06-10T00:38:39-07:00</authored-date>
  <message>Added update_yaml task to create/update yaml files, suggested by Francesc Esplugas
Added .gitignore</message>
  <tree>0369d0c282392c6067a838bb439d5ea43b416b84</tree>
  <committer>
    <name>Raul Murciano</name>
    <email>raul@murciano.net</email>
  </committer>
</commit>
