Flip on locale setting

This commit is contained in:
Petko Bordjukov 2014-09-01 12:32:03 +03:00
parent 3889dcce65
commit 6361512fe4
2 changed files with 16 additions and 1 deletions

View File

@ -3,6 +3,17 @@ class ApplicationController < ActionController::Base
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_filter :configure_permitted_parameters, if: :devise_controller?
before_action :set_locale
def default_url_options(options={})
{locale: I18n.locale}
end
private
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end
protected

View File

@ -24,7 +24,11 @@
<% end %>
<li>
<a href="#">English</a>
<% if I18n.locale != :en %>
<%= link_to 'English', root_url(locale: 'en') %>
<% elsif I18n.locale != :bg %>
<%= link_to 'Български', root_url(locale: 'bg') %>
<% end %>
</li>
</ul>
</nav>