-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Address review feedback on language override of navigator.language/s. #11922
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
base: main
Are you sure you want to change the base?
Conversation
25c9273 to
322cfa0
Compare
source
Outdated
| languages, ordered by preference with the most preferred language first. <ref>BCP47</ref></li> | ||
| languages, ordered by preference with the most preferred language first. The same object must be | ||
| returned until the user agent needs to return different values, or values in a different order, | ||
| or <var>emulatedLanguage</var> is updated. <ref>BCP47</ref></li> |
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.
To do this properly we have to store the object we intend to return on Navigator in an associated concept of sorts. And then each time we run this algorithm we see if any of the values changed, and if not, we return the cached object. And if they have changed, we update the cached object and then return it.
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.
Hmm... I'm not so sure how to specify the storing of the value 😕 Like where I could keep it. I couldn't really find anything similar in the spec, only the same kind of sentences that the value should be returned until something has changed. Should I write something abstract that there should be some kind of cache for it? Could you maybe give me some pointers/examples?
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.
Ah okay. It would be similar to
Each Window has an associated Navigator, ...
Maybe something like:
Each object that implements NavigatorLanguage has an associated plausible languages array, which is a frozen array of BCP 47 language tags. It is initially empty.
And then in the getter algorithm you could do something like:
- Let languages be the result of computing plausible languages. (I.e., what the steps do today.)
- If languages and this's plausible languages array do not have the same values in the same order, then set this's plausible languages array to languages.
- Return this's plausible languages array.
Does that help?
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.
Yes! It does 🙂
I've updated the PR. Please let me know if it looks better now.
841b0a3 to
5446bae
Compare
5446bae to
d8a55d5
Compare
d8a55d5 to
a483bd7
Compare
Addresses post-merge review comments on #11793
/system-state.html ( diff )