v0.43.1
This commit is contained in:
1 parent
5b6d4a7903
commit
4d1087e357
160 files changed
+2407
-1933
No files matched your search
@@ -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}`;
|
||||
|
||||
Reference in new issue
Block a user