+ Rails.logger.info "available_locales = #{available_locales.map(&:to_s)}"
+
+ preferred_locales = if current_user
+ current_user.preferred_languages
+ else
+ Locale.new(I18n.locale).candidates
+ end
+
+ Rails.logger.info "preferred_locales = #{preferred_locales.expand.map(&:to_s)}"
+
+ locale = available_locales.preferred(preferred_locales)
+
+ Rails.logger.info "locale = #{locale}"