Intl.Locale.prototype.baseName
Intl.Locale 实例的 baseName 访问器属性返回此语言环境的字符串表示形式的子字符串,其中包含有关此语言环境的核心信息,包括语言、脚本和区域(如果可用)。
¥The baseName accessor property of Intl.Locale instances returns a substring of this locale's string representation, containing core information about this locale, including the language, and the script and region if available.
描述
¥Description
baseName 返回 unicode_language_id 语法 的 language ["-" script] ["-" region] *("-" variant) 子序列。它仅包含构造函数中明确指定的信息,无论是通过语言环境标识符字符串还是选项对象。
¥baseName returns the language ["-" script] ["-" region] *("-" variant) subsequence of the unicode_language_id grammar. It only includes information explicitly specified in the constructor, either through the locale identifier string or the options object.
baseName 的集合访问器是 undefined。你不能直接更改此属性。
¥The set accessor of baseName is undefined. You cannot change this property directly.
示例
基本示例
输入字符串中包含选项的示例
¥Example with options in the input string
// Sets language to Japanese, region to Japan,
// calendar to Gregorian, hour cycle to 24 hours
const japan = new Intl.Locale("ja-JP-u-ca-gregory-hc-24");
console.log(japan.toString()); // Prints out "ja-JP-u-ca-gregory-hc-h24"
console.log(japan.baseName); // Prints out "ja-JP"
包含覆盖输入字符串的选项的示例
¥Example with options that override input string
// Input string indicates language as Dutch and region as Belgium,
// but options object overrides the region and sets it to the Netherlands
const dutch = new Intl.Locale("nl-Latn-BE", { region: "NL" });
console.log(dutch.baseName); // Prints out "nl-Latn-NL"
规范
| Specification |
|---|
| ECMAScript Internationalization API Specification # sec-Intl.Locale.prototype.baseName |
浏览器兼容性
BCD tables only load in the browser
也可以看看
¥See also