How do I change the browser language with Javascript

后端 未结 6 1642
谎友^
谎友^ 2020-12-10 13:39

I want to access the user browser settings and change the browser language, is this possible using Javascript?

If it\'s possible, how can I access this? (sample code

6条回答
  •  庸人自扰
    2020-12-10 14:04

    If what you actually want to do is detect the language the user is using, which is what you want to do, because nothing will annoy your visitors more that their browser preferences getting changed, on the server-side, read the Accept-Language HTTP request header that all modern browsers send, it should contain all the info you need. If it is absent, assume the language of your largest audience.

    Check out RFC2616 Section 14.4 for more information on Accept-Language and it's use.

提交回复
热议问题