Intl.Segmenter.prototype.resolvedOptions()
Baseline
2024
Newly available
Since April 2024, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
resolvedOptions() 㯠Intl.Segmenter ã¤ã³ã¹ã¿ã³ã¹ã³ã®ã¡ã½ããã§ããã® Segmenter ãªãã¸ã§ã¯ãã®åæåä¸ã«è¨ç®ããããªãã·ã§ã³ãåæ ããããããã£ãæã¤æ°ãããªãã¸ã§ã¯ããè¿ãã¾ãã
試ãã¦ã¿ã¾ããã
const segmenter = new Intl.Segmenter("fr-FR");
const options = segmenter.resolvedOptions();
console.log(options.locale);
// äºæ³ãããçµæ: "fr-FR"
console.log(options.granularity);
// äºæ³ãããçµæ: "grapheme"
æ§æ
resolvedOptions()
弿°
ãªãã
è¿å¤
ãã® Segmenter ãªãã¸ã§ã¯ãã®åæåæã«è¨ç®ããããªãã·ã§ã³ãåæ ããããããã£ãæã¤æ°ãããªãã¸ã§ã¯ãã§ãããã®ãªãã¸ã§ã¯ãã«ã¯ãè¨è¼é ã«æ¬¡ã®ããããã£ãããã¾ãã
locale-
å®éã«ä½¿ç¨ããããã±ã¼ã«ã® BCP 47 è¨èªã¿ã°ã§ããããã¯ããã±ã¼ã«ãã´ã·ã¨ã¼ã·ã§ã³ã®å¦çã«ãã£ã¦æ±ºå®ããã¾ããåºåã«ã¯ãUnicode æ¡å¼µãã¼ã¯å«ã¾ãã¾ããã
granularity-
options弿°ã§ãã®ããããã£ã«æå®ãããå¤ã§ããå¿ è¦ã«å¿ãã¦ããã©ã«ãå¤ãè¨å®ããã¾ããå¤ã¯"grapheme"ã"word"ã"sentence"ã®ããããã§ããããã©ã«ãã¯"grapheme"ã§ãã
ä¾
>åºæ¬çãªä½¿ãæ¹
const spanishSegmenter = new Intl.Segmenter("es", { granularity: "sentence" });
const options = spanishSegmenter.resolvedOptions();
console.log(options.locale); // "es"
console.log(options.granularity); // "sentence"
ããã©ã«ãã®ç²åº¦
const spanishSegmenter = new Intl.Segmenter("es");
const options = spanishSegmenter.resolvedOptions();
console.log(options.locale); // "es"
console.log(options.granularity); // "grapheme"
locale ã®ãã©ã¼ã«ããã¯
const banSegmenter = new Intl.Segmenter("ban");
const options = banSegmenter.resolvedOptions();
console.log(options.locale);
// Balinese ãã±ã¼ã«ã«å¯¾å¿ãã¦ãããã
// ããã©ã«ãã®ãã±ã¼ã«ã French ã§ããã©ã³ã¿ã¤ã ã§ã¯ã"fr"
console.log(options.granularity); // "grapheme"
仿§æ¸
| Specification |
|---|
| ECMAScript® 2027 Internationalization API Specification> # sec-intl.segmenter.prototype.resolvedoptions> |