The Intl.Displaynames()
constructor enables the translation of language, region and script display names in Javascript.
Unfortunately, this is not supported in Safari versions < 14.1.
(see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames#browser_compatibility).
How to make this work in older Safari versions?
We can use polyfills (see https://formatjs.io/docs/polyfills/intl-displaynames/) to make this work in older Safari versions.
Add the following polyfills to your code to make the
Intl.DisplayNames()
constructor work as expected:This requires the following dependencies:
After that, the constructor should be polyfilled and is ready to use. E.g.: