end
end
- def preferred_languages
+ def preferred_languages(reset = false)
+ @preferred_languages = nil if reset
@preferred_languages ||= if params[:locale]
Locale.list(params[:locale])
elsif current_user
helper_method :preferred_languages
- def set_locale
+ def set_locale(reset = false)
if current_user && current_user.languages.empty? && !http_accept_language.user_preferred_languages.empty?
current_user.languages = http_accept_language.user_preferred_languages
current_user.save
end
- I18n.locale = Locale.available.preferred(preferred_languages)
+ I18n.locale = Locale.available.preferred(preferred_languages(reset))
response.headers["Vary"] = "Accept-Language"
response.headers["Content-Language"] = I18n.locale.to_s
end
def account
- @title = t "user.account.title"
@tokens = current_user.oauth_tokens.authorized
if params[:user] && params[:user][:display_name] && params[:user][:description]
current_user.errors.add(attribute, error)
end
end
+ @title = t "user.account.title"
end
def go_public
end
if user.save
- set_locale
+ set_locale(true)
if user.new_email.blank? || user.new_email == user.email
flash.now[:notice] = t "user.account.flash update success"
before_save :encrypt_password
before_save :update_tile
after_save :spam_check
+ after_save :reset_preferred_languages
def to_param
display_name
@preferred_languages ||= Locale.list(languages)
end
+ def reset_preferred_languages
+ @preferred_languages = nil
+ end
+
def nearby(radius = NEARBY_RADIUS, num = NEARBY_USERS)
if home_lon && home_lat
gc = OSM::GreatCircle.new(home_lat, home_lon)