This commit is contained in:
Mateusz Gruszczyński committed 2026-11-28 17:36:53 +01:00
1 parent 5b6d4a7903
commit 4d1087e357
160 files changed
+2407 -1933

No files matched your search

+1 -7
View File
@@ -32,12 +32,9 @@ function activePack() { return languagePacks.get(language) || languagePacks.get(
let canonicalLocale = { source: null, value: "und" };
function locale() {
const source = activePack()?.meta.locale || "und";
if (canonicalLocale.source !== source) { let value = "und"; try { value = Intl.getCanonicalLocales(source)[0]; } catch { /* invalid tag */ } canonicalLocale = { source, value }; }
if (canonicalLocale.source !== source) { let value = "und"; try { value = Intl.getCanonicalLocales(source)[0]; } catch { } canonicalLocale = { source, value }; }
return canonicalLocale.value;
}
// Live views format hundreds of numbers and times per update; constructing a
// new Intl formatter for each value (toLocaleString with options) dominated
// that work. Formatters are cached per language and options.
const intlFormatters = new Map();
function intlFormatter(kind, key, create) {
const cacheKey = `${locale()}|${kind}|${key}`;
@@ -49,9 +46,6 @@ function formatNumber(value, maximumFractionDigits = 0) { return intlFormatter("
function formatDateParts(date, withDate, hour12) {
return intlFormatter(withDate ? "datetime" : "time", hour12, lang => new Intl.DateTimeFormat(lang, withDate ? { year: "numeric", month: "numeric", day: "numeric", hour: "numeric", minute: "numeric", second: "numeric", hour12 } : { hour: "numeric", minute: "numeric", second: "numeric", hour12 })).format(date);
}
// Sorting calls a comparator O(n log n) times; String#localeCompare with a
// locale/options argument builds a new collator on every call, which made
// periodic table re-renders slow. Collators are cached per language.
const textCollators = new Map();
function textCollator(numeric = true) {
const key = `${activePack()?.meta.locale || "und"}|${numeric}`;