refactor: migrate legacy wire namespace to wrn
Quality / quality (ubuntu-latest) (push) Failing after 9m49s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
2026-08-12 18:51:15 +05:30
parent ec23dd4c93
commit 2c960fc1dc
488 changed files with 27306 additions and 19063 deletions
+15 -15
View File
@@ -58,7 +58,7 @@ export interface ResolvedI18n {
cookie: Required<I18nCookieConfig>;
}
export const LANG_COOKIE = "wire-lang";
export const LANG_COOKIE = "wrn-lang";
export const I18N_JS_HREF = "/__wrnexus/i18n.js";
const UNSAFE_KEYS = new Set(["__proto__", "prototype", "constructor"]);
@@ -425,7 +425,7 @@ function safeJson(value: unknown): string {
export function renderI18nData(i18n: ResolvedI18n, lang: string): string {
const active = i18n.langs.includes(lang) ? lang : i18n.default;
return `window.__wireI18n=${safeJson({
return `window.__wrnI18n=${safeJson({
lang: active,
langs: i18n.langs,
default: i18n.default,
@@ -455,7 +455,7 @@ export const I18N_RUNTIME = String.raw`
return params && Object.prototype.hasOwnProperty.call(params, name) ? String(params[name]) : "{" + name + "}";
});
}
function state() { return window.__wireI18n || {}; }
function state() { return window.__wrnI18n || {}; }
function t(key, params) {
var current = state();
return interpolate(lookup(current.messages, key) || lookup(current.fallbackMessages, key) || key, params);
@@ -499,33 +499,33 @@ export const I18N_RUNTIME = String.raw`
});
function updateResponsiveLabels() {
var short = window.matchMedia && window.matchMedia("(max-width: 640px)").matches;
scope.querySelectorAll("option[data-wire-lang-option]").forEach(function (option) {
scope.querySelectorAll("option[data-wrn-lang-option]").forEach(function (option) {
option.textContent = option.getAttribute(short ? "data-label-short" : "data-label-long") || option.value;
});
}
updateResponsiveLabels();
if (!window.__wireI18nResponsiveBound && window.matchMedia) {
window.__wireI18nResponsiveBound = true;
if (!window.__wrnI18nResponsiveBound && window.matchMedia) {
window.__wrnI18nResponsiveBound = true;
window.matchMedia("(max-width: 640px)").addEventListener("change", function () { bind(document); });
}
scope.querySelectorAll("[data-wrn-preferences]").forEach(function (switcher) {
switcher.setAttribute("data-current-language", currentLang);
var label = switcher.querySelector(".wire-preferences__current-language");
var label = switcher.querySelector(".wrn-preferences__current-language");
if (label) label.textContent = String(currentLang || "en").toUpperCase();
});
scope.querySelectorAll("[data-wire-lang-set]").forEach(function (node) {
node.setAttribute("aria-pressed", String(node.getAttribute("data-wire-lang-set") === currentLang));
if (node.__wireLangBound) return; node.__wireLangBound = 1;
node.addEventListener("click", function () { set(node.getAttribute("data-wire-lang-set")); });
scope.querySelectorAll("[data-wrn-lang-set]").forEach(function (node) {
node.setAttribute("aria-pressed", String(node.getAttribute("data-wrn-lang-set") === currentLang));
if (node.__wrnLangBound) return; node.__wrnLangBound = 1;
node.addEventListener("click", function () { set(node.getAttribute("data-wrn-lang-set")); });
});
scope.querySelectorAll("select[data-wire-lang]").forEach(function (node) {
scope.querySelectorAll("select[data-wrn-lang]").forEach(function (node) {
node.value = currentLang;
if (node.__wireLangBound) return; node.__wireLangBound = 1;
if (node.__wrnLangBound) return; node.__wrnLangBound = 1;
node.addEventListener("change", function () { set(node.value); });
});
}
window.__wireLang = { set: set, t: t, bind: bind, get lang() { return state().lang; } };
window.__wireI18n = Object.assign(state(), { t: t, set: set });
window.__wrnLang = { set: set, t: t, bind: bind, get lang() { return state().lang; } };
window.__wrnI18n = Object.assign(state(), { t: t, set: set });
if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", function () { bind(document); });
else bind(document);
})();