mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-02 01:53:03 +08:00
This PR extends the current setting `content_localization_anonymous_language_switcher` to one that can be shown even for logged in users -> `content_localization_language_switcher` When logged in, the preference is saved to the `user` rather than a cookie. 🍪 https://github.com/user-attachments/assets/b6f4d41b-4716-4020-a97d-2c3f90d54576
17 lines
444 B
Ruby
17 lines
444 B
Ruby
# frozen_string_literal: true
|
|
|
|
class LanguageSwitcherSettingValidator
|
|
def initialize(opts = {})
|
|
@opts = opts
|
|
end
|
|
|
|
def valid_value?(val)
|
|
return true if val == "none"
|
|
SiteSetting.set_locale_from_cookie && SiteSetting.allow_user_locale &&
|
|
SiteSetting.content_localization_supported_locales.present?
|
|
end
|
|
|
|
def error_message
|
|
I18n.t("site_settings.errors.content_localization_language_switcher_requirements")
|
|
end
|
|
end
|