lib/translations_ennder/rails.rb in translations_ennder-1.0.1 vs lib/translations_ennder/rails.rb in translations_ennder-1.0.2

- old
+ new

@@ -23,29 +23,31 @@ puts "Railx V3.x.y, init_translations_ennder()" init_translations_ennder end -class ApplicationController - # Instance methods here - def set_locale - if (params[:locale] and params[:locale].match /^(en|fr)$/) - I18n.locale = params[:locale] - elsif session[:locale].nil? - _http_lang = request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first - if _http_lang.match /^(en|fr)$/ - I18n.locale = _http_lang +module ActionController + class Base + # Instance methods here + def set_locale + if (params[:locale] and params[:locale].match /^(en|fr)$/) + I18n.locale = params[:locale] + elsif session[:locale].nil? + _http_lang = request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first + if _http_lang.match /^(en|fr)$/ + I18n.locale = _http_lang + else + I18n.locale = :fr + end else - I18n.locale = :fr + I18n.locale = session[:locale] || :fr end - else - I18n.locale = session[:locale] || :fr - end -# logger.debug "locale=[#{session[:locale]}]" + # logger.debug "locale=[#{session[:locale]}]" - if session[:locale] != I18n.locale - session[:locale] = I18n.locale + if session[:locale] != I18n.locale + session[:locale] = I18n.locale + end end end end