Tin mới
the parameter description on the Intl main page
The Intl object is very use-case driven. It provides a separate object for each use case that requires locale-specific logic. Currently, it provides the following functionalities:
Intl.Locale.prototype.maximize()
Locales underlie all behaviors of Intl. A locale is a set of conventions, represented in the Intl API by the Intl.Locale object. All Intl constructors that accept language tags also accept Intl.Locale objects.
Intl.DateTimeFormat.supportedLocalesOf()
A shared concern for internationalization is: how do I know what locale to use?
Understanding the return value
Temporal.PlainDate.prototype.toLocaleString()
A major use case of Intl is to output locale-specific texts representing structured data. This is similar to translation software, but instead of letting you translate arbitrary text, it takes data such as dates, numbers
The Intl.Collator object is useful for comparing and sorting strings. It takes two strings and returns a number indicating their relative order, in the same way as the compareFn argument of the Array.prototype.sort metho
UTF-16 code units and Unicode code points
The Intl.Segmenter object is useful for breaking a string into segments. Without Intl, you are already able to split a string by UTF-16 code units and Unicode code points:
After introducing so many options and behaviors, you may wonder how to present them to the user. Intl comes with two useful APIs for building user interfaces: Intl.supportedValuesOf() and Intl.DisplayNames.
Temporal.ZonedDateTime.prototype.toLocaleString()
Intl.DateTimeFormat formats dates and times, as well as ranges of dates and times. The DateTimeFormat object takes date/time inputs in one of the following forms: Date, Temporal.PlainDateTime, Temporal.PlainTime, Tempora
Number formatting is done with the Intl.NumberFormat object. The NumberFormat object accepts inputs in the form of numbers, strings, or BigInt values. Passing a string or BigInt instead of a number allows you to format n
Intl.RelativeTimeFormat formats a time difference. The RelativeTimeFormat object takes relative times in the form of two arguments: a number (with any sign) and a time unit, such as "day", "hour", or "minute".
Intl.DurationFormat provides duration formatting, such as "3 hours, 4 minutes, 5 seconds". It is not a primitive operation with its own formatter: it uses Intl.NumberFormat and Intl.ListFormat internally to format each d