Fabio Manniti
Fabio Manniti

Reputation: 115

Is browser language always in the same format?

Through , I am detecting my browser language

    function detectLanguage(){
        return navigator.language || navigator.userLanguage;
    }

and it returns me en-EN. I would like to know: is always this the format of the string? Like "two small letters" - "same two capital letters"?

Upvotes: 1

Views: 1674

Answers (1)

Daiquery
Daiquery

Reputation: 28

The “format” (it’s a header, thanks Adriani6) is called Accept-Language.

The "two small letters and two capital letters" will most definitely not be the same all of the time.

For example, if your browser requested French as used in Canada, you would receive "fr-CA".

For more information, check out the W3C website.

Similar questions:
Get visitors language & country code with javascript (client-side)
Best way to determine user's locale within browser

Upvotes: 1

Related Questions