Accesskey n skips to in-page navigation. Skip to the content start.

s_gotoW3cHome Internationalization
 

FAQ: Setting language preferences in a browser

Intended audience: users who want to configure their user agent/browser to automatically download pages in a given language when available (assuming that there are alternate pages on the server, and that the server is set up to negotiate between them).

Question

How do I check or change the language settings of my browser?

Background

When your browser pulls a document from the Web, it sends a request to the server where the information is stored. This is known as an HTTP request. With the request, the browser sends information about its language preference settings. (These are preferences about the preferred language of pages, not the user interface of the browser.)

The part of the HTTP request that holds this language preference information is called the Accept-Language request-header. If the server stores alternate versions of a page or resource in more than one language, the Accept-Language information can be used to retrieve the page in your preferred language, if it is available. If there is only one version of a page on the server, that version will be retrieved, through a process known as HTTP content negotiation.

Mainstream browsers allow you to modify these language preferences. The value itself should conform to RFC 4646 (Tags for the Identification of Languages). It is typically as a two or three letter language code (eg. fr for French), followed by optional subcodes representing such things as country (eg. fr-CA represents French as spoken in Canada).

In many cases, the initial browser setting is okay. For example, if you have a Japanese version of a browser, the browser typically assumes that you prefer pages in Japanese, and sends this information to the server. This FAQ tells you how to change the language preference expressed by your user agent.

Answer

To check or change the settings in the following popular browsers, use the menu commands shown below:

These paths change from time to time as new versions of a browser are released. The data here was correct last time we looked. Please let us know if the information is out of date.

Command sequences for additional browsers can be found at http://www.debian.org/intro/cn#mozilla

Specifying alternatives

You can specify several alternatives that will be treated in order of preference. The following example shows a setting in Internet Explorer 6 for someone who would prefer Swiss French pages, but if that is not available would settle for any French, German or English page, in that order.

A screen-grab of the Internet Explorer dialog box for changing Language Preferences.

Most browsers will allow you to select the languages you want from a list. You may also be able to specify custom language preferences. If you do so, you need to use values that will be recognized by the server (see below).

Your preferences should always be ordered from most to least specific, top to bottom. This generally means, if you use multiple subtags then include shorter tags lower down the list.

Important. Some of the server-side language selection mechanisms require an exact match to the Accept-Language header. If a document on the server is tagged as fr (French) then a request for a document matching fr-CH (French as spoken in Switzerland) will fail.

To ensure success you should configure your browser to request both fr-CH and fr, in that order. (See the example in the picture above.) This will cause the server to look for a Swiss French version first, but failing that, look for a French version.

Finding and using custom tags

You will normally be able to select the language tag you want from a list provided by your browser. This section tells you how to create your own language tags.

The information in this section should meet your needs most of the time. If you want to know more about the syntax of language tags, see the article Language tags in HTML and XML.

Your language tag must start with a two- or three-letter code, called a subtag, from the list of languages specified in the IANA Language Subtag Registry. You may then add a second subtag to indicate a country or region, if you wish. These subtags can also be found in the registry. The first and second subtags must be separated by a hyphen.

Language. The IANA Language Subtag Registry is a long text file. To find a language subtag, search for the name of that language, in English. If we search for 'French', we find a record that looks like this:

Type: language
Subtag: fr
Description: French
Added: 2005-10-16
Suppress-Script: Latn

Note that the type of this record is 'language'. You use the code nearby that is labelled 'Subtag', ie. 'fr'.

Region. If you want to add a region subtag, such as CA for fr-CA (French as spoken in Canada), search for the name of the country or region. If you search for 'Canada' you will find a record like this:

Type: region
Subtag: CA
Description: Canada
Added: 2005-10-16

Note that this is a subtag of type 'region', which is what you want. Use the 'CA' subtag (to end up with fr-CA).

Subtags to avoid. You should avoid subtags that are described in the registry as redundant or deprecated. There are other types of subtag available in the registry, but, generally speaking, it is very unlikely that you would need to use them currently for this purpose (because people are unlikely to use the other subtags to label documents on the server).

Chinese. The registry also contains subtags for scripts, but these are not normally needed, and so should be avoided. One exception is the script tag for Chinese.

Chinese people, though they may speak mutually unintelligible dialects or languages, typically write what they want to say in the same way, distinguishing only between Simplified and Traditional forms of Chinese characters. If you are looking for Chinese information, therefore, you may want to simply specify whether the text is in simplified or traditional script, rather than in a specific language.

Due to the absence in the past of a way to refer to script in language subtags, servers tended to return text in traditional script if your language setting said zh-TW (Chinese as spoken in Taiwan), and in simplified script if your settings said zh-CN (Chinese as spoken in Mainland China). If your settings said zh-SG (Chinese as spoken in Singapore) or zh-HK (Chinese as spoken in Hong Kong), it is less clear that you will get back what you expect (normally simplified and traditional Chinese, respectively).

The IANA registry now also contains subtags for scripts. The Hans and Hant script tags in the registry allow you to specify preferences for zh-Hans (simplified Chinese) or zh-Hant (traditional Chinese).

It may be worth doing this, as people begin to label their resources using these tags on the server. However, you should also include other alternatives, to catch older servers that still use the old approach. For example, if you are living in Taiwan you may want to set up a list of preferences as follows:

zh-Hant
zh-TW
zh

Note that you should probably avoid using script tags for other languages in browser settings, though if you do, you should use them only as with alternative language tags - not in the only item in your preferences.

IE7

When you install a copy of Internet Explorer 7, your preferences are automatically set according to the Windows user locale, although you are given the opportunity to modify this when you first install.

Note that, if you haven't customized your browser's language preferences, when you change the Windows user locale the browser preferences get changed too. If you customize the browser settings, they no longer follow the changes in the Windows user locale. (The Windows user locale settings allow you to switch formats, such as which character is used as the decimal separator, the order of date information, etc. by selecting different locales.)

The values sent in the Accept-Language request-header from IE7 are typically of the form language-region. There is typically no language-only form. For example, if you are French your Accept-Language header will present fr-FR to the server.

There are some servers that are unable to match fr-FR against a document labelled on the server as fr. To avoid missing out on French resources from such sites you may want to add the fr as an alternative preference (after the fr-FR). You can do this by clicking on the 'Add' button in the language preferences dialog, and typing fr into the 'Custom' field.

By the way

A nice example of the use of language negotiation is the Press Release of the W3C Spanish Office’s Standards Tour in 2004, available in Spanish, Basque, Catalan, and Galician, as well as Japanese and French. To try this out, set your preferences to each of the available Iberian peninsular languages in turn, and click on this link after each change. The codes you need are es (Spanish), eu (Basque), ca (Catalan) and gl (Gallician).

You can also try language negotiation out with this example of a language-negotiated page: The CSS2 Press Release (available in Dutch, English, German, and Japanese).

Tell us what you think (English).

Subscribe to an RSS feed.

New resources

Home page news

Further reading

Author: Martin Dürst & Richard Ishida, W3C.

Valid XHTML 1.0!
Valid CSS!
Encoded in UTF-8!

Content first published 2003-10-30. Last substantive update 2006-09-27 10:27 GMT. This version 2006-10-20 07:59 GMT

For the history of document changes, search for qa-lang-priorities in the i18n blog.