Skip to content

Commit

Permalink
add interactive examples for intl/segmenter et al. (#14124)
Browse files Browse the repository at this point in the history
* add interactive examples for intl/segmenter et al. after mdn/interactive-examples#1987

* Apply suggestions from code review

Co-authored-by: Jean-Yves Perrier <jypenator@gmail.com>

Co-authored-by: Jean-Yves Perrier <jypenator@gmail.com>
  • Loading branch information
SphinxKnight and teoli2003 committed Mar 21, 2022
1 parent 221f6c5 commit 46c0f52
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 0 deletions.
Expand Up @@ -13,6 +13,8 @@ browser-compat: javascript.builtins.Intl.Segmenter

The **`Intl.Segmenter`** object enables locale-sensitive text segmentation, enabling you to get meaningful items (graphemes, words or sentences) from a string.

{{EmbedInteractiveExample("pages/js/intl-segmenter.html")}}

## Constructor

- [`Intl.Segmenter()`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/Segmenter)
Expand Down
Expand Up @@ -13,6 +13,8 @@ browser-compat: javascript.builtins.Intl.Segmenter.resolvedOptions

The **`Intl.Segmenter.prototype.resolvedOptions()`** method returns a new object with properties reflecting the locale and granularity options computed during the initialization of this [`Intl.Segmenter`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter) object.

{{EmbedInteractiveExample("pages/js/intl-segmenter-prototype-resolvedoptions.html")}}

## Syntax

```js
Expand Down
Expand Up @@ -13,6 +13,8 @@ browser-compat: javascript.builtins.Intl.Segmenter.segment

The **`Intl.Segmenter.prototype.segment()`** method segments a string according to the locale and granularity of this [`Intl.Segmenter`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter) object.

{{EmbedInteractiveExample("pages/js/intl-segmenter-prototype-segment.html")}}

## Syntax

```js
Expand Down
Expand Up @@ -14,6 +14,8 @@ browser-compat: javascript.builtins.Intl.Segmenter.constructor

The **`Intl.Segmenter()`** constructor creates [`Intl.Segmenter`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter) objects that enable locale-sensitive text segmentation.

{{EmbedInteractiveExample("pages/js/intl-segmenter.html")}}

## Syntax

```js
Expand Down
Expand Up @@ -13,6 +13,8 @@ browser-compat: javascript.builtins.Intl.Segmenter.supportedLocalesOf

The **`Intl.Segmenter.supportedLocalesOf()`** method returns an array containing those of the provided locales that are supported without having to fall back to the runtime's default locale.

{{EmbedInteractiveExample("pages/js/intl-segmenter-supportedlocalesof.html")}}

## Syntax

```js
Expand Down
Expand Up @@ -13,6 +13,8 @@ browser-compat: javascript.builtins.Intl.Segments.@@iterator

The **`Intl.Segments.@@iterator`** method is part of [the iterable protocol](/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol), which returns a new iterator object that can iterate over the entries in an `Intl.Segmenter` object. Each entry is returned as an object.

{{EmbedInteractiveExample("pages/js/intl-segments-prototype-@@iterator.html")}}

## Syntax

```js
Expand Down
Expand Up @@ -13,6 +13,8 @@ browser-compat: javascript.builtins.Intl.Segments.containing

The **`Intl.Segments.containing()`** method returns an object describing the segment in the string that includes the code unit at the specified index.

{{EmbedInteractiveExample("pages/js/intl-segments-prototype-containing.html")}}

## Syntax

```js
Expand Down
Expand Up @@ -13,6 +13,8 @@ browser-compat: javascript.builtins.Intl.Segments

An **`Intl.Segments`** instance is an iterable collection of the segments of a text string. It is returned by a call to the [`segment()`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/segment) method of an [`Intl.Segmenter`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter) object.

{{EmbedInteractiveExample("pages/js/intl-segments-prototype-containing.html")}}

## Instance methods

- [`Segments.prototype.containing()`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segments/containing)
Expand Down

0 comments on commit 46c0f52

Please sign in to comment.