Kristian Mandrup
2010-Apr-29 01:35 UTC
How are path segments in Rails 3? needed for upgrade of translate_routes plugin
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
http://github.com/kristianmandrup/translate_routes
Original Rails 2 version
http://github.com/gonzoyumo/translate_routes/blob/master/lib/translate_routes.rb
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!
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To post to this group, send email to rubyonrails-core@googlegroups.com.
To unsubscribe from this group, send email to
rubyonrails-core+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en.