Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial set of live examples for Intl.Segmenter et al. #1987

Merged
merged 2 commits into from Mar 18, 2022

Conversation

SphinxKnight
Copy link
Member

As a companion for mdn/content#8402

SphinxKnight added a commit to SphinxKnight/content that referenced this pull request Jan 5, 2022
teoli2003 pushed a commit to mdn/content that referenced this pull request Jan 10, 2022
* Hydrated stub pages with metadata and structure; first drafts of constructor and supportedLocalesOf pages

* Segmenter examples (#4)

* make spanish_segmenter more... modern?

* add example and syntax to Segmenter#resolvedOptions

* add example and syntax to Segmenter#segment

* add information about segment data objects

* Hit the 80-20 point on Intl.Segmenter

* Update files/en-us/web/javascript/reference/global_objects/intl/segmenter/constructor/index.md

Co-authored-by: Richard Gibson <richard.gibson@gmail.com>

* Apply suggestions from code review

Co-authored-by: Richard Gibson <richard.gibson@gmail.com>

* Update files/en-us/web/javascript/reference/global_objects/intl/segmenter/constructor/index.md

Co-authored-by: Richard Gibson <richard.gibson@gmail.com>

* Update files/en-us/web/javascript/reference/global_objects/intl/segmenter/constructor/index.md

Co-authored-by: Richard Gibson <richard.gibson@gmail.com>

* Fixed constructor structure

* Fixed constructor structure

* Apply suggestions from code review

Co-authored-by: Richard Gibson <richard.gibson@gmail.com>

* Update files/en-us/web/javascript/reference/global_objects/intl/segmenter/segments/index.md

Co-authored-by: Richard Gibson <richard.gibson@gmail.com>

* Update files/en-us/web/javascript/reference/global_objects/intl/segmenter/index.md

Co-authored-by: Richard Gibson <richard.gibson@gmail.com>

* Fixed main index link reference

* Fixed code block error

* Wrote the @@iterator page

* Apply suggestions from code review

Co-authored-by: wbamberg <will@bootbonnet.ca>

* Rework tree structure per @Elchi3 comment

* Remove exotic whitespace/gremlin

* Add interactive examples (cf. mdn/interactive-examples#1987)

* Remove jsxref, fix links, normalize tags

* Taking review comments into account, improving examples

* Update files/en-us/web/javascript/reference/global_objects/intl/segmenter/index.md

Co-authored-by: wbamberg <will@bootbonnet.ca>

* Update files/en-us/web/javascript/reference/global_objects/intl/segmenter/index.md

Co-authored-by: wbamberg <will@bootbonnet.ca>

* Update files/en-us/web/javascript/reference/global_objects/intl/segmenter/index.md

Co-authored-by: wbamberg <will@bootbonnet.ca>

* Update files/en-us/web/javascript/reference/global_objects/intl/segmenter/index.md

Co-authored-by: wbamberg <will@bootbonnet.ca>

* Update files/en-us/web/javascript/reference/global_objects/intl/segmenter/segment/index.md

Co-authored-by: wbamberg <will@bootbonnet.ca>

* Update files/en-us/web/javascript/reference/global_objects/intl/segmenter/segmenter/index.md

Co-authored-by: wbamberg <will@bootbonnet.ca>

* Update files/en-us/web/javascript/reference/global_objects/intl/segments/containing/index.md

Co-authored-by: wbamberg <will@bootbonnet.ca>

* Update files/en-us/web/javascript/reference/global_objects/intl/segments/@@iterator/index.md

Co-authored-by: wbamberg <will@bootbonnet.ca>

* Update files/en-us/web/javascript/reference/global_objects/intl/segmenter/supportedlocalesof/index.md

Co-authored-by: wbamberg <will@bootbonnet.ca>

* Update files/en-us/web/javascript/reference/global_objects/intl/segments/index.md

Co-authored-by: wbamberg <will@bootbonnet.ca>

* Remove interactive example due to Fx missing impl.

* sort methods alphabetically

* Update files/en-us/web/javascript/reference/global_objects/intl/segments/@@iterator/index.md

Co-authored-by: wbamberg <will@bootbonnet.ca>

* Favor const

* improve example while condition

* Update files/en-us/web/javascript/reference/global_objects/intl/segments/containing/index.md

Co-authored-by: wbamberg <will@bootbonnet.ca>

* DLify localeMatcher

* this one needs to be let

Co-authored-by: Ujjwal Sharma <ryzokuken@disroot.org>
Co-authored-by: Richard Gibson <richard.gibson@gmail.com>
Co-authored-by: Romulo Cintra <romulocintra@users.noreply.github.com>
Co-authored-by: wbamberg <will@bootbonnet.ca>
Co-authored-by: julieng <julien.gattelier@gmail.com>
Co-authored-by: SphinxKnight <SphinxKnight@users.noreply.github.com>
Copy link
Member

@teoli2003 teoli2003 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

@wbamberg wbamberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SphinxKnight , these examples look great, but I think it's worth considering if it's possible to make some of them shorter.

We'd like to keep examples to 12 lines or less, then they fit in the "standard" editor and generally fit nicely in the page. We do go over that when we have to (e.g. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/Proxy/preventExtensions) but it's not ideal.

In this PR 4/6 examples are "big". Can we make any of them shorter without compromising clarity or illustrative power? For example, https://github.com/mdn/interactive-examples/pull/1987/files#diff-58e8adc19b4b1ddad231f391c5d74f8fb16a43bb29c18b58bb1ae73551f5cf07 uses 7 lines for the output comment. Perhaps we could instead do something like:

const segmenterFr = new Intl.Segmenter('fr', { granularity: 'word' });
const string1 = 'Que ma joie demeure';

const iterator1 = segmenterFr.segment(string1)[Symbol.iterator]();

for (const segment of iterator1) {
  if (segment.segment.length > 4) {
    console.log(segment.segment);
  }
}

// expected output: "demeure"

? Or maybe something better.

@SphinxKnight
Copy link
Member Author

@wbamberg sorry for slacking here, I'll get back to this in the coming days :x

Copy link
Contributor

@wbamberg wbamberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 thank you @SphinxKnight !

@wbamberg wbamberg merged commit 54dd8b7 into mdn:main Mar 18, 2022
teoli2003 added a commit to mdn/content that referenced this pull request Mar 21, 2022
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants