const localizeLocaleOptions = () => { const localeSelect = document.querySelector("#login-select-toggle"); if (!(localeSelect instanceof HTMLSelectElement)) return; for (const option of localeSelect.options) { const optionUrl = new URL(option.value, window.location.origin); const locale = optionUrl.searchParams.get("kc_locale"); if (locale === "zh-CN") option.textContent = "简体中文"; if (locale === "en") option.textContent = "English"; } }; if (document.readyState === "loading") { document.addEventListener("DOMContentLoaded", localizeLocaleOptions, { once: true, }); } else { localizeLocaleOptions(); }