Load the Intl.Segmenter and Intl.DurationFormat polyfills only if needed (#2778)

* Load the Intl.Segmenter polyfill only if needed

* Also polyfill Intl.DurationFormat only if needed

* Polyfill Intl.* in tests

* Load the default translations in tests

* Instanciate the Intl.DurationFormat in the component
This commit is contained in:
Quentin Gliech
2024-11-14 19:06:38 +01:00
committed by GitHub
parent 6e5c468780
commit 137a53dbee
6 changed files with 60 additions and 31 deletions

View File

@@ -6,6 +6,7 @@ Please see LICENSE in the repository root for full details.
*/
import "matrix-js-sdk/src/@types/global";
import type { DurationFormat as PolyfillDurationFormat } from "@formatjs/intl-durationformat";
import { Controls } from "../controls";
declare global {
@@ -23,4 +24,9 @@ declare global {
// Safari only supports this prefixed, so tell the type system about it
webkitRequestFullscreen: () => void;
}
namespace Intl {
// Add DurationFormat as part of the Intl namespace because we polyfill it
const DurationFormat: typeof PolyfillDurationFormat;
}
}