Skip to content

Conversation

@exterkamp
Copy link
Member

Summary
Allow custom formatted ICU {var, number, bytes} to be nested inside {var, plural, ...} ICU blocks, and have it be formatted properly

Related Issues/PRs
fixes: #9378

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

thanks for cleaning this up for realz @exterkamp! :D

* Note: This function will recursively inspect plural elements for nested arguementElements.
*
* @param {Array<import('intl-messageformat-parser').Element>} parsedIcu
* @param {Map<string, import('intl-messageformat-parser').Element>} elements
Copy link
Collaborator

Choose a reason for hiding this comment

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

unexpected that this returned a map, can we add the return type explicitly?

Co-Authored-By: Patrick Hulce <[email protected]>
*
* Note: This function will recursively inspect plural elements for nested arguementElements.
*
* @param {Array<import('intl-messageformat-parser').Element>} elementsList
Copy link
Contributor

Choose a reason for hiding this comment

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

typically we just use plurals for arrays of things unless the list gives extra info about the value. I like @patrickhulce's earlier suggestion of icuElements (or messageElements...plain old elements is confusing in web-related terminology :) for this, personally.

Copy link
Contributor

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

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

some last naming things, but otherwise LGTM!

what do you think about a follow up PR to add a check in collect-strings that there aren't strings that will run into the same issue as the one in resource-summary so we don't have to wait for translation feedback that we messed up again? Not worth it or easy to check?

(we maybe also want to add guidance to the readme on how things should be nested)

@brendankenny
Copy link
Contributor

@patrickhulce over to you

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

LGTM!

* @param {Array<import('intl-messageformat-parser').Element>} icuElements
* @param {Map<string, import('intl-messageformat-parser').Element>} seenElementsById
*/
function _collectAllCustomElementsFromICU(icuElements, seenElementsById = new Map()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

what an awesome journey this function as had...

it's so. good. now :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

resource-summary cannot be translated

4 participants