Created
May 3, 2011 22:01
-
-
Save Marchino/954356 to your computer and use it in GitHub Desktop.
Change page locale and translate url
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul id="choose_language"> | |
<% I18n.available_locales.each do |locale| %> | |
<li class="<%=locale.to_s%>"> | |
<a href="http://<%=locale==I18n.default_locale ? 'www' : locale.to_s%>.mydomain.dev/pages/change_locale?url=<%=request.path%>" rel="nofollow"><span>en</span></a> | |
</li> | |
<% end %> | |
</ul> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PagesController < ApplicationController | |
def change_locale | |
path = ActionController::Routing::Routes.recognize_path params[:url] | |
redirect_to path | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment