Flip on locale setting
This commit is contained in:
parent
3889dcce65
commit
6361512fe4
|
@ -3,6 +3,17 @@ class ApplicationController < ActionController::Base
|
||||||
# For APIs, you may want to use :null_session instead.
|
# For APIs, you may want to use :null_session instead.
|
||||||
protect_from_forgery with: :exception
|
protect_from_forgery with: :exception
|
||||||
before_filter :configure_permitted_parameters, if: :devise_controller?
|
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
|
protected
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,11 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<li>
|
<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>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
Loading…
Reference in New Issue