Intl.Locale.prototype.caseFirst
Intl.Locale
实例的 caseFirst
访问器属性返回此区域设置的排序规则是否考虑大小写。
¥The caseFirst
accessor property of Intl.Locale
instances returns whether case is taken into account for this locale's collation rules.
描述
¥Description
区域设置的排序规则用于确定字符串在该区域设置中的排序方式。某些区域设置在排序过程中使用字符的大小写(大写或小写)。该附加规则可以用 Intl.Locale
对象的 caseFirst
属性来表达。
¥A locale's collation rules are used to determine how strings are ordered in that locale. Certain locales use a character's case (UPPERCASE or lowercase) in the collation process. This additional rule can be expressed in a Intl.Locale
object's caseFirst
property.
caseFirst
属性可以有 3 个值,如下表所示。
¥There are 3 values that the caseFirst
property can have, outlined in the table below.
caseFirst
值
示例
通过区域设置字符串设置 caseFirst 值
¥Setting the caseFirst value via the locale string
在 Unicode 语言环境字符串规范 中,caseFirst
代表的值对应于键 kf
。kf
被视为区域设置字符串 "扩展子标签"。这些子标签添加有关区域设置的附加数据,并使用 -u
扩展键添加到区域设置标识符。因此,可以将 caseFirst
值添加到传递到 Locale
构造函数的初始区域设置标识符字符串中。要添加 caseFirst
值,请首先将 -u
扩展键添加到字符串中。接下来,添加 -kf
扩展键以指示你要添加 caseFirst
的值。最后,将 caseFirst
值添加到字符串中。
¥In the Unicode locale string spec, the values that caseFirst
represents correspond to the key kf
. kf
is treated as a locale string "extension subtag". These subtags add additional data about the locale, and are added to locale identifiers by using the -u
extension key. Thus, the caseFirst
value can be added to the initial locale identifier string that is passed into the Locale
constructor. To add the caseFirst
value, first add the -u
extension key to the string. Next, add the -kf
extension key to indicate that you are adding a value for caseFirst
. Finally, add the caseFirst
value to the string.
const locale = new Intl.Locale("fr-Latn-FR-u-kf-upper");
console.log(locale.caseFirst); // Prints "upper"
通过配置对象参数设置 caseFirst 值
¥Setting the caseFirst value via the configuration object argument
Intl.Locale()
构造函数有一个可选的配置对象参数,可用于传递扩展类型。将配置对象的 caseFirst
属性设置为所需的 caseFirst
值,然后将其传递到构造函数中。
¥The Intl.Locale()
constructor has an optional configuration object argument, which can be used to pass extension types. Set the caseFirst
property of the configuration object to your desired caseFirst
value, and then pass it into the constructor.
const locale = new Intl.Locale("en-Latn-US", { caseFirst: "lower" });
console.log(locale.caseFirst); // Prints "lower"
规范
Specification |
---|
ECMAScript Internationalization API Specification # sec-Intl.Locale.prototype.caseFirst |
浏览器兼容性
BCD tables only load in the browser
也可以看看
¥See also