-
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
i18n: accept array of locales in lookupLocale #11349
Conversation
lighthouse-core/lib/i18n/i18n.js
Outdated
* @param {string=} locale | ||
* @return {LH.Locale} | ||
* @return {LH.Locale|undefined} | ||
*/ | ||
function lookupLocale(locale) { |
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.
paul suggested perhaps we should accept an array of locales here and do the "try the next value" in LH core.
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.
Fun fact: both Intl.getCanonicalLocales
and lookupClosestLocale
already take string|Array<string>|undefined
:)
Can we use that to reduce work and custom resolution logic here?
it('falls back to root tag prefix if specific locale not available', () => { | ||
expect(i18n.lookupLocale('en-JKJK')).toEqual('en'); | ||
expect(i18n.lookupLocale('es-JKJK')).toEqual('es'); |
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.
test case was conflated with the default fallback behavior.
Wait, is there a bug in |
I think that's just our local d.ts declaration |
@connorjclark do you mind updating the docs to mention the array behavior? To clear up how prefix shortening and array order interact in precedence, for instance. |
ref https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2382176/comment/979304b7_ee2df92f/