No, not Intel. Intl is a JavaScript object containing the functions of formatting numbers, dates and string comparisons. It comes because on April 29, Firefox, the last of the popular browsers that does not support Intl, is updated to version 29, in which internationalization support will be enabled.Intl.Collator - Constructor of a class that allows to perform string comparisons based on locale.Intl.DateTimeFormat - Constructor class allows you to format the date and time, taking into account the localeIntl.NumberFormat - Constructor of a class containing the functions of formatting numbers. In accordance with the locale, of course.locale and options . new Intl.Collator([locales [, options]]) but functions can also be applied to existing objects using Intl.Collator.call(this [, locales [, options]]) Now in order console.log(new Intl.Collator("de", {sensitivity: "base"}).compare("ä", "a")); // 0 console.log(new Intl.Collator("sv", {sensitivity: "base"}).compare("ä", "a")); // 1 Yes, Swedish and German have a different alphabet. The sensitivity option is just responsible for understanding and can take the following values: "base" // a ≠ b, a = á, a = A. "accent" // a ≠ b, a ≠ á, a = A. "case" // a ≠ b, a = á, a ≠ A. "variant" // a ≠ b, a ≠ á, a ≠ A. console.log(new Intl.Collator("ru", {numeric: true}).compare("3", "21")); // -1 console.log(new Intl.Collator("ru", {numeric: false}).compare("3", "21")); // 1 usage parameter, with the possible values of sort and search , which also affects the comparison, but I don’t set the goal of this article to fully describe the Intl object, it’s still better than in the documentation - it will not work.ignorePunctuation . The name speaks for itself and needs only an illustrative example: console.log(new Intl.Collator("ru", {ignorePunctuation: true}).compare("!", "")); // 0 console.log(new Intl.Collator("ru", {ignorePunctuation: false}).compare("!", "")); // 1 timeZone Browsers are required to understand only UTC, but they can support other time zones. Unfortunately, this remains on the conscience of developers.hour12 Explanations, I think, does not require. I can only say that the default value depends on the locale. Nice how! var date = new Date(); console.log(new Intl.DateTimeFormat("de-DE", { weekday: "long", year: "numeric", month: "long", day: "numeric"}).format(date)); // Samstag, 5. April 2014 console.log(new Intl.DateTimeFormat("ru", { weekday: "short", year: "2-digit", month: "long", day: "numeric"}).format(date)); // , 5 14 . console.log(new Intl.DateTimeFormat("ar-EG", { weekday: "narrow", year: "numeric", month: "long", day: "numeric"}).format(date)); // ٢٠١٤ , console.log(new Intl.NumberFormat("ru-RU",{minimumIntegerDigits: 7}).format(-123)); // -0 000 123 console.log(new Intl.NumberFormat("ru-RU",{minimumIntegerDigits: 7, minimumFractionDigits: 5, maximumFractionDigits: 7}).format(-12.345)); // -0 000 012,34500 By default, maximumFractionDigits is set to 3 and therefore you should not forget about it.useGrouping option to false. console.log(new Intl.NumberFormat("ru-RU",{minimumIntegerDigits: 7, useGrouping: false}).format(-12.345)); // -0000012,345 console.log(new Intl.NumberFormat("de-DE", {style: "currency", currency: "EUR"}).format(12.345)); // 12,345 € console.log(new Intl.NumberFormat("ja-JP", {style: "currency", currency: "JPY"}).format(12.345)); //¥12.345 console.log(new Intl.NumberFormat("ja-JP", {style: "currency", currency: "EUR"}).format(12.345)); // €12.345 Source: https://habr.com/ru/post/218481/
All Articles