Re: [i18n-drafts] [questions/qa-when-lang-neg] Language negotiation using client-side JavaScript (#545)

`navigator.languages` can be used if the content is generated client-side.

Currently, when you open a ReSpec document, you may see errors/warnings in the upper right corner. When you click the "error/warning pill", you will see errors in English. If ReSpec supports multiple languages, it might use `navigator.languages` to generate the error messages in the language the user wants to see.

The ReSpec example might not be very good, tho. For some web applications, the entire application is generated using JavaScript. In this case, `navigator.languages` is a potential solution, especially when the application developer has no control over the server.

Here are some real code examples for your reference:

* [@nuxtjs/i18n](https://i18n.nuxtjs.org/api/composables#usebrowserlocale)
* [ice.js](https://github.com/alibaba/ice/blob/99635bceee18644fe260f7661f5fcfb3ab76653a/packages/plugin-i18n/src/utils/getPreferredLocale.ts#L7-L13)
* [Video.js](https://github.com/videojs/video.js/blob/cd2dac4b82fe309e89ecf25317a9869daa2edc2a/src/js/player.js#L5297)

-- 
GitHub Notification of comment by xfq
Please view or discuss this issue at https://github.com/w3c/i18n-drafts/issues/545#issuecomment-1765736011 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 17 October 2023 06:15:02 UTC