Initial set of live examples for Intl.Segmenter et al.#1987
Initial set of live examples for Intl.Segmenter et al.#1987
Conversation
* 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 <[email protected]> * Apply suggestions from code review Co-authored-by: Richard Gibson <[email protected]> * Update files/en-us/web/javascript/reference/global_objects/intl/segmenter/constructor/index.md Co-authored-by: Richard Gibson <[email protected]> * Update files/en-us/web/javascript/reference/global_objects/intl/segmenter/constructor/index.md Co-authored-by: Richard Gibson <[email protected]> * Fixed constructor structure * Fixed constructor structure * Apply suggestions from code review Co-authored-by: Richard Gibson <[email protected]> * Update files/en-us/web/javascript/reference/global_objects/intl/segmenter/segments/index.md Co-authored-by: Richard Gibson <[email protected]> * Update files/en-us/web/javascript/reference/global_objects/intl/segmenter/index.md Co-authored-by: Richard Gibson <[email protected]> * Fixed main index link reference * Fixed code block error * Wrote the @@iterator page * Apply suggestions from code review Co-authored-by: wbamberg <[email protected]> * 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 <[email protected]> * Update files/en-us/web/javascript/reference/global_objects/intl/segmenter/index.md Co-authored-by: wbamberg <[email protected]> * Update files/en-us/web/javascript/reference/global_objects/intl/segmenter/index.md Co-authored-by: wbamberg <[email protected]> * Update files/en-us/web/javascript/reference/global_objects/intl/segmenter/index.md Co-authored-by: wbamberg <[email protected]> * Update files/en-us/web/javascript/reference/global_objects/intl/segmenter/segment/index.md Co-authored-by: wbamberg <[email protected]> * Update files/en-us/web/javascript/reference/global_objects/intl/segmenter/segmenter/index.md Co-authored-by: wbamberg <[email protected]> * Update files/en-us/web/javascript/reference/global_objects/intl/segments/containing/index.md Co-authored-by: wbamberg <[email protected]> * Update files/en-us/web/javascript/reference/global_objects/intl/segments/@@iterator/index.md Co-authored-by: wbamberg <[email protected]> * Update files/en-us/web/javascript/reference/global_objects/intl/segmenter/supportedlocalesof/index.md Co-authored-by: wbamberg <[email protected]> * Update files/en-us/web/javascript/reference/global_objects/intl/segments/index.md Co-authored-by: wbamberg <[email protected]> * 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 <[email protected]> * Favor const * improve example while condition * Update files/en-us/web/javascript/reference/global_objects/intl/segments/containing/index.md Co-authored-by: wbamberg <[email protected]> * DLify localeMatcher * this one needs to be let Co-authored-by: Ujjwal Sharma <[email protected]> Co-authored-by: Richard Gibson <[email protected]> Co-authored-by: Romulo Cintra <[email protected]> Co-authored-by: wbamberg <[email protected]> Co-authored-by: julieng <[email protected]> Co-authored-by: SphinxKnight <[email protected]>
There was a problem hiding this comment.
@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.
|
@wbamberg sorry for slacking here, I'll get back to this in the coming days :x |
wbamberg
left a comment
There was a problem hiding this comment.
👍 thank you @SphinxKnight !
* add interactive examples for intl/segmenter et al. after mdn/interactive-examples#1987 * Apply suggestions from code review Co-authored-by: Jean-Yves Perrier <[email protected]> Co-authored-by: Jean-Yves Perrier <[email protected]>
As a companion for mdn/content#8402