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.
This commit is contained in:
David Taylor 2023-12-12 21:09:14 +00:00 committed by GitHub
parent 097cef7d21
commit 0f3a6cf042
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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, <a href="https://www.discourse.org/faq/#browser">your browser is unsupported</a>. Please <a href="https://browsehappy.com">switch to a supported browser</a> to view rich content, log in and reply.';