Intl.Locale.prototype.baseName
Baseline
Widely available
This feature is well established and works across many devices and browser versions. Itâs been available across browsers since 2020å¹´9æ.
baseName 㯠Intl.Locale ã¤ã³ã¹ã¿ã³ã¹ã®ã¢ã¯ã»ãµã¼ããããã£ã§ããã®ãã±ã¼ã«ã®æåå表ç¾ã®ä¸é¨ãè¿ãã¾ãããã®é¨åæååã«ã¯ãå©ç¨ã§ããå ´åãè¨èªãã¹ã¯ãªãããå°åãããªã¢ã³ããªã©ããã®ãã±ã¼ã«ã«é¢ããåºæ¬æ
å ±ãå«ã¾ãã¦ãã¾ãã
解説
baseName 㯠è¨èª ["-" æåä½ç³»] ["-" å°å] *("-" variant) ã®å½¢ã§ unicode_language_id æ§æã®é¨åæååãè¿ãã¾ããã³ã³ã¹ãã©ã¯ã¿ã¼å
ã§æç¤ºçã«æå®ãããæ
å ±ã®ã¿ãå«ã¿ã¾ããããã¯ãã±ã¼ã«èå¥åæååã¾ãã¯ãªãã·ã§ã³ãªãã¸ã§ã¯ããéãã¦è¡ããã¾ãã
baseName ã®è¨å®ã¢ã¯ã»ãµã¼ã¯ undefined ã§ãããã®ããããã£ãç´æ¥å¤æ´ãããã¨ã¯ã§ãã¾ããã
ä¾
>åºæ¬çãªä¾
const myLoc = new Intl.Locale("fr-Latn-CA"); // ãã±ã¼ã«ãã«ããã®ãã©ã³ã¹èªã«è¨å®
console.log(myLoc.toString()); // "fr-Latn-CA-u-ca-gregory" ã¨è¡¨ç¤º
console.log(myLoc.baseName); // "fr-Latn-CA" ã¨è¡¨ç¤º
å ¥åæååã®ãªãã·ã§ã³ä»ãã®ä¾
// è¨èªãæ¥æ¬èªãå°åãæ¥æ¬ã«è¨å®ããã
// ã«ã¬ã³ãã¼ãã°ã¬ã´ãªãªæ¦ãæå¶ã 24 æå¶ã«ãã
const japan = new Intl.Locale("ja-JP-u-ca-gregory-hc-24");
console.log(japan.toString()); // "ja-JP-u-ca-gregory-hc-h24" ã¨è¡¨ç¤º
console.log(japan.baseName); // "ja-JP" ã¨è¡¨ç¤º
å ¥åæååã䏿¸ããããªãã·ã§ã³ä»ãã®ä¾
// å
¥åæååã¯è¨èªããªã©ã³ãèªãå°åããã«ã®ã¼ã§ãããã¨ã示ãã¦ãã¾ããã
// ãã ãããªãã·ã§ã³ãªãã¸ã§ã¯ãã§å°åã䏿¸ããã¦ããããªã©ã³ãã«è¨å®ãã¦ãã¾ã
const dutch = new Intl.Locale("nl-Latn-BE", { region: "NL" });
console.log(dutch.baseName); // "nl-Latn-NL" ã¨è¡¨ç¤º
仿§æ¸
| Specification |
|---|
| ECMAScript® 2027 Internationalization API Specification> # sec-Intl.Locale.prototype.baseName> |