I have solved. I added to controllers/application_controller.rb
this:
before_filter :set_locale
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end
private
def default_url_options(options={})
logger.debug "default_url_options is passed options: #{options.inspect}\n"
{ :locale => I18n.locale }
end
Then I added this to views/layouts/_header.html.erb
:
<li><% if I18n.locale == I18n.default_locale %>
<%= link_to "Türkçe", :locale=>'tr'%>
<% else %>
<%= link_to "English", :locale=>'en'%>
<%end%></li>
Then to config/routes.rb
this:
scope "(:locale)", :locale => /en|tr/ do # at the beginning
match '/home' , to: 'static_pages#home'
match '/help' , to: 'static_pages#help'
match '/about' , to: 'static_pages#about'
.....
end
Thats it!