MRoderick
2008-Apr-26 17:52 UTC
Routing: Language as first part of path, for just about everything
Hi Group Like others before me have posted to the group, I am trying to implement routes that have language as the first part of the path, without having to rewrite just about every url generating statement across the codebase (my own, plugins, tests, etc). Let''s start with an example: map.login ''/:lang/login'', :controller => ''sessions'', :action => ''new'' map.resources :categories, :path_prefix => '':lang'' Having looked around, I managed to find two plugins, that get''s me half-way there: http://www.artweb-design.de/2007/5/13/concise-localized-rails-url-helpers-solved-twice More specifically resource_fu and localized_url_helpers Adding either of these and setting a default language in default_url_options, it''s easy to get a nice default value for named routes def default_url_options(options) { :lang => ''en'' } end But, what do I do with non-named routes? link_to :controller => ''categories'', :action => ''index'' won''t work, as it won''t have the lang parameter specified automagically. Something tells me that I am looking at this from a "less-than- optimal" angle, so any advice is welcome /Morgan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---