Sort out storage and use of user preferred languages.
[rails.git] / app / controllers / application.rb
index 3d16ffa6954d22db95c3f2bad0d00c70cdceef33..c5624db146b4cdbfb86d03f84308c2d6f721f96e 100644 (file)
@@ -102,6 +102,15 @@ class ApplicationController < ActionController::Base
   end
   
   def set_locale
+    if @user
+      if !@user.languages.empty?
+        request.user_preferred_languages = @user.languages
+      elsif !request.user_preferred_languages.empty?
+        @user.languages = request.user_preferred_languages
+        @user.save
+      end
+    end
+
     I18n.locale = request.compatible_language_from(I18n.available_locales)
   end