A platform for community discussion. Free, open, simple.
FIX: Dasherize locale correctly for messageformat setup (#37268)
David Taylor93caa5dbfdab
diff --git a/frontend/discourse-i18n/src/index.js b/frontend/discourse-i18n/src/index.jsindex d1f1af97d01..2f35166b395 100644--- a/frontend/discourse-i18n/src/index.js+++ b/frontend/discourse-i18n/src/index.js@@ -493,7 +493,7 @@ export class I18n {"@messageformat/runtime": MessageFormatRuntime,});- const messages = new Messages(msgData, this.locale);+ const messages = new Messages(msgData, this.locale.replaceAll("_", "-"));messages.defaultLocale = "en";this._mfMessages = messages;}diff --git a/spec/system/locale_spec.rb b/spec/system/locale_spec.rbindex e782c8e68eb..3d4d564c1b1 100644--- a/spec/system/locale_spec.rb+++ b/spec/system/locale_spec.rb@@ -9,6 +9,7 @@ RSpec.describe "Locale choice", type: :system dotext: I18n.t("js.filters.categories.title", locale: :en),)expect(page.evaluate_script("moment.locale()")).to eq("en")+ expect(page.evaluate_script("I18n._mfMessages.locale")).to eq("en")endit "loads french locale successfully" do@@ -20,6 +21,19 @@ RSpec.describe "Locale choice", type: :system dotext: I18n.t("js.filters.categories.title", locale: :fr),)expect(page.evaluate_script("moment.locale()")).to eq("fr")+ expect(page.evaluate_script("I18n._mfMessages.locale")).to eq("fr")+ end++ it "loads polish locale successfully" do+ SiteSetting.default_locale = "pl_PL"+ visit "/"+ expect(page).to have_css("html[lang='pl-PL']")+ expect(page).to have_css(+ "#navigation-bar .categories",+ text: I18n.t("js.filters.categories.title", locale: :pl_PL),+ )+ expect(page.evaluate_script("moment.locale()")).to eq("pl")+ expect(page.evaluate_script("I18n._mfMessages.locale")).to eq("pl-PL")endcontext "with test locales" do