I have been trying to upgrade the translate_routes plugin from Rails 2 to 3. Looking into the Rails 3 source, I can't seem to gem a grip on how the Path Segments are handled now. Maybe it has to do with the new Rack way of doing things?
Fx a url could have a date at the end in the form of :yy/:mm/:dd, which you don't want to translate. The route posts/:id on the other hand has a static part 'posts' (static segment) which you could translate, whereas the :id is a dynamic segment. Then you would look up the static segments in a locale file to translate it to the action to execute... poste (french) mapped to action posts#index
My attempt at a Rails 3 port
Original Rails 2 version
Example of Rails 2 use of static segments taken from the Rails 2 version of translate_routes:
def self.original_static_segments static_segments = (@@original_routes || Routes.routes).each do |r| r.segments.select do |s| static_segments << s.value if s.instance_of? (ActionController::Routing::StaticSegment) end end static_segments.uniq.sort end
What is the Rails 3 equivalent I wonder?
If used in combination with the I18n plugin by Sven Fuchs, this would allow for a complete i18n Rails 3 solution I think.
Thanks!