Baseline Widely available
Intl.ListFormat
ãªãã¸ã§ã¯ãã¯ãè¨èªãèæ
®ãããªã¹ãã®æ´å½¢ãã§ããããã«ãã¾ãã
const vehicles = ["Motorcycle", "Bus", "Car"];
const formatter = new Intl.ListFormat("en", {
style: "long",
type: "conjunction",
});
console.log(formatter.format(vehicles));
// Expected output: "Motorcycle, Bus, and Car"
const formatter2 = new Intl.ListFormat("de", {
style: "short",
type: "disjunction",
});
console.log(formatter2.format(vehicles));
// Expected output: "Motorcycle, Bus oder Car"
const formatter3 = new Intl.ListFormat("en", { style: "narrow", type: "unit" });
console.log(formatter3.format(vehicles));
// Expected output: "Motorcycle Bus Car"
ã³ã³ã¹ãã©ã¯ã¿ã¼
Intl.ListFormat()
æ°ãã Intl.ListFormat
ãªãã¸ã§ã¯ãã使ãã¾ãã
Intl.ListFormat.supportedLocalesOf()
æå®ãããã±ã¼ã«ã®ãã¡ãã©ã³ã¿ã¤ã ã®æ¢å®ã®ãã±ã¼ã«ã«ä»£æ¿ããããã¨ãªã対å¿ãã¦ãããã®ãå«ãé åãè¿ãã¾ãã
Intl.ListFormat.prototype.format()
ãªã¹ãã®è¦ç´ ã表ããè¨èªãèæ ®ãã¦æ¸å¼åãããæååãè¿ãã¾ãã
Intl.ListFormat.prototype.formatToParts()
ãã±ã¼ã«ãèæ ®ããæ¹æ³ã§å¤ã®ãªã¹ããæ¸å¼åããããã«ä½¿ç¨ã§ããããã¾ãã¾ãªé¨åã表ããªãã¸ã§ã¯ãã®é åãè¿ãã¾ãã
Intl.ListFormat.prototype.resolvedOptions()
ç¾å¨ã® Intl.ListFormat
ãªãã¸ã§ã¯ãã®æ§ç¯æã«è¨ç®ããããã±ã¼ã«ããã³ã¹ã¿ã¤ã«ã®æ¸å¼åãªãã·ã§ã³ãåæ ããããããã£ãæã¤ãæ°ãããªãã¸ã§ã¯ããè¿ãã¾ãã
次ã®ä¾ã¯ãè±èªã使ç¨ãããªã¹ããã©ã¼ããã¿ã¼ã®ä½ææ¹æ³ã§ãã
const list = ["Motorcycle", "Bus", "Car"];
console.log(
new Intl.ListFormat("en-GB", { style: "long", type: "conjunction" }).format(
list,
),
);
// > Motorcycle, Bus and Car
console.log(
new Intl.ListFormat("en-GB", { style: "short", type: "disjunction" }).format(
list,
),
);
// > Motorcycle, Bus or Car
console.log(
new Intl.ListFormat("en-GB", { style: "narrow", type: "unit" }).format(list),
);
// > Motorcycle Bus Car
formatToParts ã®ä½¿ç¨
次ã®ä¾ã§ã¯ãæ´å½¢æ¸ã¿ã®é¨åãè¿ããªã¹ããã©ã¼ããã¿ã¼ãçæããæ¹æ³ã示ãã¾ãã
const list = ["Motorcycle", "Bus", "Car"];
console.log(
new Intl.ListFormat("en-GB", {
style: "long",
type: "conjunction",
}).formatToParts(list),
);
// [ { "type": "element", "value": "Motorcycle" },
// { "type": "literal", "value": ", " },
// { "type": "element", "value": "Bus" },
// { "type": "literal", "value": ", and " },
// { "type": "element", "value": "Car" } ];
仿§æ¸ ãã©ã¦ã¶ã¼ã®äºææ§ é¢é£æ
å ±
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4