0

I m trying to use i18n with rails, but there was a mistake I did not handle.

config/initiliazers/locale.rb

I18n.load_path += Dir[Rails.root.join('lib', 'locale', '*.{rb,yml}')]
I18n.default_locale = :tr

config/application.rb

config.i18n.default_locale = :tr

production.rb

config.i18n.fallbacks = true

belows are methods that I configure the language

application_controller.rb

def set_language
  I18n.locale = params[:lang] || I18n.locale
  redirect_to request.referrer
end

sessions_controller.rb

def new
logger.debug "* Accept-Language: #{request.env['HTTP_ACCEPT_LANGUAGE']}"
if (extract_locale_from_accept_language_header == "tr")
  I18n.locale = extract_locale_from_accept_language_header
else
  I18n.locale = "en"  
end  
logger.debug "* Locale set to '#{I18n.locale}'"

end

in the server, when I click a link the language changes continuously although the link is not about the language

Ramazan Zor
  • 209
  • 1
  • 14

1 Answers1

0

The post Ruby on Rails网站语言国际化 tell you how to do.

hww
  • 11
  • 2