-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
core(i18n): throw on excess placeholder replacement values #9580
Conversation
expect(icuMessagePaths).toEqual({ | ||
[templateID]: [{path: 'audits[fake-audit].title', values: {x: 1}}]}); | ||
[expectedPathId]: [{path: 'audits[fake-audit].title', values: {x: 1}}]}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dangers of singletons :) this test was implicitly relying on the test above having called createMessageInstanceIdFn
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
sirNotAppearingInThisString: 66, | ||
}); | ||
expect(_ => i18n.getFormatted(helloStr, 'en-US')) | ||
// eslint-disable-next-line max-len |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
apparently we've decided there's disagreement on this point so we should never use disable-next-line max-len
again :P
@exterkamp I'm gonna love this convo next week where I can learn how splitting is possibly better 😆
some unit tests are still unhappy about spanish locale swap though |
db8cb07
to
9103f12
Compare
ok, with #9598 in, the tests for this should now all pass 🤞 |
we have a check that all arguments in an ICU message have values passed into our i18n functions; this PR adds a check that all the values passed in have a place to be used in the ICU message. This is useful when strings change since we have no type checking that our localized strings match the values being passed in for replacement.
I was originally going to include this in #9570, but ran into a ton of errors in our unit tests. Turns out this is just because
LHError
always includeserrorCode
in the replacement values so you don't have to write'NO_FCP'
three times just to get aNO_FCP
error. I added a comment to remind the next person abouterrorCode
.This condition currently only happens in one place (the change in #9486 removing
itemCount
), but removingitemCount
reveals a flaw in our system: if the ICU arguments in a string aren't provided invalues
, we throw an error (and if we don't throw one,intl-messageformat
does). This is an issue when the other locale files have strings with different ICU arguments than the en-US one does (as is currently case forthird-party-summary.js | displayValue
).This is a pretty fundamental issue so going to fix that before landing this :)