Navigator objects about the properties of a language

Source: Internet
Author: User

"Summary" when doing an internationalized Web project, I encountered a problem of switching the default language version according to the natural language used by the user's browser. So, organized this article.

First , W3cschool about navigator The various attribute values are very clear, here no longer repeat.

then , The differences are analyzed from the Navigator objects of each browser on the attributes of the language.

1.Google Chrome's Navigator:

As you can see, Google Chrome has two attributes for languages: language and languages. The former is to return to the current browser language, which is the browser's all available language versions (Google Chrome can add the required language in the advanced settings and can switch to the language you want to use.) In this way, it is possible to test the ability to set the current language version automatically by default in multi-language versions.

2. Firefox's navigator:

Firefox also has two properties for languages: language and languages.

The navigator of 3.IE8 and IE9:

(1) IE8 and the following versions:

IE8 has two properties:systemlanguage and userlanguage. The former is the default language that returns the current operating system, which is the natural language that returns the operating system settings.

And look at IE9 and above:

IE9 has three properties:systemlanguage: Returns the default language of the current operating system;Userlanguage: Returns the natural language set by the operating system;Browserlanguage : Returns the current browser language.

"Summary" the various browsers support the language related attributes in the following table:

Property IE8 and the following versions IE9 and above versions Firefox/chrome/safari Opera
Language X X
Userlanguage X
Systemlanguage X X
Browserlanguage X X

You can use the following code to get the current browser language:

(Navigator.language | | navigator.browserlanguage). toLowerCase ()

Navigator objects about the properties of a language

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.