DEV: Simplify I18n shim check (#24244)

We have identified some third-party analytics scripts which do things like `window.I18n = window.I18n` 🤦‍♂️. This leads to the window object having a null I18n property, but `"I18n" in globalThis` returns true.

This commit checks whether `window.I18n` is a truthy value.
This commit is contained in:
David Taylor 2023-11-06 16:54:39 +00:00 committed by GitHub
parent 047cae4b3f
commit 76b75fae36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,4 @@
if ("I18n" in globalThis) {
if (window.I18n) {
throw new Error(
"I18n already defined, discourse-i18n unexpectedly loaded twice!"
);