Intl.Segmenter.prototype.resolvedOptions()
Baseline 2024Newly available
Since April 2024, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
Die Methode resolvedOptions()
von Instanzen von Intl.Segmenter
gibt ein neues Objekt zurück, das Eigenschaften enthält, die die während der Initialisierung dieses Segmenter
-Objekts berechneten Optionen widerspiegeln.
Probieren Sie es aus
const segmenter1 = new Intl.Segmenter("fr-FR");
const options1 = segmenter1.resolvedOptions();
console.log(options1.locale);
// Expected output: "fr-FR"
console.log(options1.granularity);
// Expected output: "grapheme"
Syntax
resolvedOptions()
Parameter
Keine.
Rückgabewert
Ein neues Objekt mit Eigenschaften, die die während der Initialisierung dieses Segmenter
-Objekts berechneten Optionen widerspiegeln. Das Objekt hat die folgenden Eigenschaften in der angegebenen Reihenfolge:
locale
-
Der BCP 47-Sprachcode für die tatsächlich verwendete Locale, ermittelt durch den Locale-Aushandlungsprozess. Es wird kein Unicode-Erweiterungsschlüssel in der Ausgabe enthalten sein.
granularity
-
Der Wert, der in den
options
-Argumenten für diese Eigenschaft angegeben wurde, mit standardmäßiger Auffüllung, falls erforderlich. Es ist entweder"grapheme"
,"word"
oder"sentence"
. Der Standardwert ist"grapheme"
.
Beispiele
Grundlegende Nutzung
const spanishSegmenter = new Intl.Segmenter("es", { granularity: "sentence" });
const options = spanishSegmenter.resolvedOptions();
console.log(options.locale); // "es"
console.log(options.granularity); // "sentence"
Standardmäßige Granularität
const spanishSegmenter = new Intl.Segmenter("es");
const options = spanishSegmenter.resolvedOptions();
console.log(options.locale); // "es"
console.log(options.granularity); // "grapheme"
Fallback-Locale
const banSegmenter = new Intl.Segmenter("ban");
const options = banSegmenter.resolvedOptions();
console.log(options.locale);
// "fr" on a runtime where the Balinese locale
// is not supported and French is the default locale
console.log(options.granularity); // "grapheme"
Spezifikationen
Specification |
---|
ECMAScript® 2025 Internationalization API Specification # sec-intl.segmenter.prototype.resolvedoptions |
Browser-Kompatibilität
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
resolvedOptions |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support