This commit is contained in:
2025-11-02 19:17:20 +08:00
parent ebf784146e
commit e71b69db5f
2575 changed files with 1242294 additions and 95 deletions

View File

@@ -0,0 +1,55 @@
import { Lazy } from './lazy.js';
import { LANGUAGE_DEFAULT } from './platform.js';
export const safeIntl = {
DateTimeFormat(locales, options) {
return new Lazy(() => {
try {
return new Intl.DateTimeFormat(locales, options);
}
catch {
return new Intl.DateTimeFormat(undefined, options);
}
});
},
Collator(locales, options) {
return new Lazy(() => {
try {
return new Intl.Collator(locales, options);
}
catch {
return new Intl.Collator(undefined, options);
}
});
},
Segmenter(locales, options) {
return new Lazy(() => {
try {
return new Intl.Segmenter(locales, options);
}
catch {
return new Intl.Segmenter(undefined, options);
}
});
},
Locale(tag, options) {
return new Lazy(() => {
try {
return new Intl.Locale(tag, options);
}
catch {
return new Intl.Locale(LANGUAGE_DEFAULT, options);
}
});
},
NumberFormat(locales, options) {
return new Lazy(() => {
try {
return new Intl.NumberFormat(locales, options);
}
catch {
return new Intl.NumberFormat(undefined, options);
}
});
}
};
//# sourceMappingURL=date.js.map