From 0f3a6cf042b526ca26afe0e9d228e2730b62dc35 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Tue, 12 Dec 2023 21:09:14 +0000 Subject: [PATCH] DEV: Improve browser-update compatibility (#24852) Now that we're using native `import()`, our main JS bundles might not even be parse-able by older browsers. In that case, `I18n` will never be defined, and so we need to account for that situation in the browser-update code. --- app/assets/javascripts/discourse/scripts/browser-update.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/scripts/browser-update.js b/app/assets/javascripts/discourse/scripts/browser-update.js index f3525b5d0ac..8ec7ecaccbc 100644 --- a/app/assets/javascripts/discourse/scripts/browser-update.js +++ b/app/assets/javascripts/discourse/scripts/browser-update.js @@ -45,8 +45,8 @@ } // retrieve localized browser upgrade text - var t = I18n.t("browser_update"); // eslint-disable-line no-undef - if (t.indexOf(".browser_update]") !== -1) { + var t = window.I18n && I18n.t("browser_update"); // eslint-disable-line no-undef + if (!t || t.indexOf(".browser_update]") !== -1) { // very old browsers might fail to load even translations t = 'Unfortunately, your browser is unsupported. Please switch to a supported browser to view rich content, log in and reply.';