A platform for community discussion. Free, open, simple.
FIX: Locale mismatch at theme translations picker (#26687)
Gabriel Grubbadc996a1e5c3a
diff --git a/app/assets/javascripts/admin/addon/controllers/admin-customize-themes-show.js b/app/assets/javascripts/admin/addon/controllers/admin-customize-themes-show.jsindex 453e8180e8b..a6c6f838419 100644--- a/app/assets/javascripts/admin/addon/controllers/admin-customize-themes-show.js+++ b/app/assets/javascripts/admin/addon/controllers/admin-customize-themes-show.js@@ -302,7 +302,11 @@ export default class AdminCustomizeThemesShowController extends Controller {}get locale() {- return this.get("model.locale") || this.siteSettings.default_locale;+ return (+ this.get("model.locale") ||+ this.userLocale ||+ this.siteSettings.default_locale+ );}@actiondiff --git a/app/assets/javascripts/admin/addon/routes/admin-customize-themes-show.js b/app/assets/javascripts/admin/addon/routes/admin-customize-themes-show.jsindex 55e65959173..f1377754b3a 100644--- a/app/assets/javascripts/admin/addon/routes/admin-customize-themes-show.js+++ b/app/assets/javascripts/admin/addon/routes/admin-customize-themes-show.js@@ -41,6 +41,7 @@ export default class AdminCustomizeThemesShowRoute extends Route {colorSchemes: parentController.get("model.extras.color_schemes"),editingName: false,editingThemeSetting: false,+ userLocale: parentController.get("model.extras.locale"),});this.handleHighlight(model);diff --git a/app/controllers/admin/themes_controller.rb b/app/controllers/admin/themes_controller.rbindex 3767e39db85..16c1c50729b 100644--- a/app/controllers/admin/themes_controller.rb+++ b/app/controllers/admin/themes_controller.rb@@ -176,6 +176,7 @@ class Admin::ThemesController < Admin::AdminControllerthemes: serialize_data(@themes, ThemeSerializer),extras: {color_schemes: serialize_data(@color_schemes, ColorSchemeSerializer),+ locale: current_user.effective_locale,},}diff --git a/spec/system/admin_customize_themes_spec.rb b/spec/system/admin_customize_themes_spec.rbindex be62b4b6da9..0403aef2510 100644--- a/spec/system/admin_customize_themes_spec.rb+++ b/spec/system/admin_customize_themes_spec.rb@@ -3,7 +3,7 @@describe "Admin Customize Themes", type: :system dofab!(:color_scheme)fab!(:theme)- fab!(:admin)+ fab!(:admin) { Fabricate(:admin, locale: "en") }let(:admin_customize_themes_page) { PageObjects::Pages::AdminCustomizeThemes.new }@@ -160,5 +160,33 @@ describe "Admin Customize Themes", type: :system dotheme_translations_settings_editor.fill_in("Hello World in French")theme_translations_settings_editor.saveend++ it "should match the current user locale translation" do+ SiteSetting.allow_user_locale = true+ SiteSetting.set_locale_from_accept_language_header = true+ SiteSetting.default_locale = "fr"++ theme.set_field(+ target: :translations,+ name: "en",+ value: { en: { group: { hello: "Hello there!" } } }.deep_stringify_keys.to_yaml,+ )+ theme.set_field(+ target: :translations,+ name: "fr",+ value: { fr: { group: { hello: "Bonjour!" } } }.deep_stringify_keys.to_yaml,+ )+ theme.save!++ visit("/admin/customize/themes/#{theme.id}")++ theme_translations_settings_editor =+ PageObjects::Components::AdminThemeTranslationsSettingsEditor.new++ expect(theme_translations_settings_editor.get_input_value).to have_content("Hello there!")++ theme_translations_picker = PageObjects::Components::SelectKit.new(".translation-selector")+ expect(theme_translations_picker.component.text).to eq("English (US)")+ endendend