I am looking for a way to find the best locale supported by my web application for a given user.
For example, my application supports the locales en_GB
and es_MX
and the browser supports fr
and en_US
. In that case the user would want to see en_GB
.
I have used the locale
package before, which does exactly that, but it only works on the server-side as it uses the Accept-Language
header.
How can I do this using navigator.languages
in the browser?