diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 948c310..6cb183d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -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 diff --git a/app/views/layouts/_nav.html.erb b/app/views/layouts/_nav.html.erb index b606851..9f4ca84 100644 --- a/app/views/layouts/_nav.html.erb +++ b/app/views/layouts/_nav.html.erb @@ -24,7 +24,11 @@ <% end %>
  • - English + <% if I18n.locale != :en %> + <%= link_to 'English', root_url(locale: 'en') %> + <% elsif I18n.locale != :bg %> + <%= link_to 'Български', root_url(locale: 'bg') %> + <% end %>