How do I use the language settings of my browser to specify the language in which a server should send me pages?
Sometimes a server may determine which language to send to you in a way that doesn't rely on the Accept-Language information. For example, Google tends to use IP information to determine the language you will receive. The browser settings discussed here do not affect content negotiation based on this kind of mechanism.
Most desktop browsers have settings that allow you to check or change the language preference settings. These tell the server what language you prefer for pages and resources that it sends you (separately from the language of the browser user interface). See the next section for examples of how to change these settings. However, for browsers on mobile devices (and at least one on the desktop), the language preferences are likely to be determined by the operating system settings, or in some cases by the language of the system when you installed the browser.
Browsers that allow you to change your language preferences will generally allow you to specify a list of languages, so that if your first choice is not available you can say what alternative languages to try, and in what order.
If your browser is set to request a language for a specific region, such as Canadian French, you should ensure that there is another language tag listed after it with just the vanilla language subtag (ie. just French in this case).
You can use the Internationalization Checker to discover the language(s) currently being requested by your browser.
In many cases, the initial browser setting will meet your needs. 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. The details below tell you how to discover and change the language preferences if you need to.
This section sets the scene by briefly describing the technical details behind what is going on.
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.
The HTTP request carries this language preference information in the Accept-Language
header. If the server
is set up to return alternate versions of a page or resource in more than one language, and the language you prefer is available, it will go through a process known
as HTTP content negotiation to find content in the language(s) indicated in the HTTP request. If there is only one version of a page on the server, that version will be retrieved. If none of the languages you request are available, the server should be set up to return a default language choice.
Most mainstream browsers allow you to modify the language preferences that your browser sends with the HTTP request. The value itself should conform to BCP 47 (Tags for the Identification of Languages). It is typically 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 used in Canada). Regions can include larger areas than countries. If you set Spanish for Latin America, you are likely to set es-419
. (Learn more about language tags.)
When the browser preferences include multiple languages, the browser will assign a qvalue (quality value) to each of the languages lower down the list. This is a kind of weighting system that is supposed to help the server understand the order in which you prefer the languages. Here is an example of an Accept-Language
header with multiple languages. Danish is preferred. If that fails, British English is requested, and finally any type of English.
Accept-Language: da, en-gb;q=0.8, en;q=0.7
You can typically specify several alternatives that will be treated in order of preference. The following example shows a setting in Firefox 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.
To ensure success you should configure your browser to request both fr-CH
and fr
, in that order. This will cause the server to look for a Swiss French version first, but failing that, look for any French version before going on to German.
Chrome will automatically set this up in the Accept-Language
header that is sent by your browser, even though you won't see the vanilla language listed in the dialog box, but most browsers don't. It's best to start by checking what your Accept-Language
header is currently set to, make some adjustments, and then check again.
Before changing your preferences you might want to check what your Accept-Language
header is currently set to.
Run the Internationalization Checker on any page, then in the Information
panel, look under Request Headers
> Accept-Language
.
See an example using this page.
We list here examples of how you would change the language settings for recent versions of a number of popular browsers on Windows or OS X desktop platforms. We use the latest versions of those browsers at the time that this article was written.
These instructions 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 and older versions of browsers can be found at https://www.debian.org/intro/cn#setting.
For most mobile devices, your preferences are set according to the primary language of your system. This makes some sense, since a mobile device is typically a personal item.
Edge. Open the Regions & language page in Settings and select the option to add a language. In many cases, you will be asked to select a region at the same time. Once you have made your selection(s), move or remove languages in the list to establish your preferred order. Restart Edge.
If you choose a language+region combination, Edge will automatically set both a language tag for the language+region and a following tag for just the vanilla language in your Accept-Language
request. In the dialog box listing languages, however, you will only see the language with the region. For example, if you choose Español (América Latina), Edge will automatically add es-419
followed by es
in your Accept-Language
request, although you will only see Español (América Latina) in the dialog box.
If you then add Spanish for Mexico to the list, you will automatically end up with es-419
, es-MX
and es
, in that order, although you will still only see Español (América Latina) followed by Español (México) in the dialog box.
You can create custom language tags by typing the BCP-47 tag for the language you wish to add in the search box of the Add a language page in the Desktop Control Panel (see a picture). In such cases, the script of the language tag must be one supported by Windows. For example, typing tlh-Latn in the Search box returns Klingon (tlh-Latn) and adds tlh-Latn
to the Accept-Language
request.
Chrome. Open the browser settings, and in the advanced section scroll down to find Languages. Open Language and Input Settings and add the language or language+region choice you want from the list available. Order the resulting list so that it is in descending order of preference. You don't need to restart Chrome.
If you choose a language+region combination, Chrome will set that option followed by just the vanilla language. For example, if you choose French (Canada), Chrome will add that followed by French
in your on-screen preference list.
If you then add French (Switzerland), it will add that choice to the bottom of your list and you will need to manually move the French (Switzerland) choice before the vanilla French choice in the dialog box.
You can't create custom language tags.
Firefox. Open the browser settings and the Content tab. Under the Languages heading, choose your preferred language(s) by selecting the language or language+region combination you want from the list provided. Then adjust the order to indicate your order of preference.
If you choose a language+region combination, Firefox will just add that option to your list and you will need to manually add the vanilla language just after it. For example, if you choose French/Canada [fr-ca], Firefox will add just that to your list and you will need to add French [fr] after it yourself.
If you subsequently add French/Switzerland [fr-ch] you'll need to move it above the vanilla French item.
You can't create custom language tags using the standard interface. (You can, however, via about:config
, using intl.accept_languages
if you are geeky enough.)
Safari. On OS X the language sent is that specified in the OS X system language preferences. To change those preferences go to System Preferences > Language & Region > Preferred Language, but be aware that it will change the language of your user interface, not just your browser language preferences. Make sure you know how to switch back to your normal language!
You can have a long list of languages in this dialog box, but Safari will only send the top item with the Accept-Language
header. If you select English (U.K.) in the preferences, the browser will send en-gb
in the Accept-Language header (and nothing else).
You can't create custom language tags.
The basic rule here is that if your language preference list contains a language tag containing a hyphen, such as fr-CH
(French as spoken in Switzerland), you should consider adding an additional language tag without the hyphen, ie. fr
(French) in this case, immediately after.
This is because if a server follows the HTTP/1.1 specification literally, it is unable to match fr-CH
against a document labelled on the server as fr
.
In practice, a server such as Apache will actually still produce a result in this case. This is because the server adds an implicit fr
preference to the list.
This preference is, however, added with a very low priority. While Apache's workaround may solve the problem if your language preference list contains only a single language, you can run into problems if you have specified more than one. The Apache documentation explains this as follows:
Implicitly, Apache will add the parent language to the client's acceptable language list with a very low quality value. But note that if the client requests "en-GB; q=0.9, fr; q=0.8", and the server has documents designated "en" and "fr", then the "fr" document will be returned. This is necessary to maintain compliance with the HTTP/1.1 specification and to work effectively with properly configured clients.
Let's look at an example. The language preference list in the image in the previous section will always return a French document on an Apache server labeled as fr
, because the French [fr] choice is explicitly listed, immediately after French/Switzerland [fr-ch]. If we remove French [fr] from the list, however, even though the Apache server adds an implicit French [fr] value, it has a lower quality value than the German [de], and therefore a German version of the document will be returned if no Swiss-French version is available (even though a version labeled as French is available).
You can try out language negotiation with this example of a language-negotiated page: The CSS2 Press Release (available in Dutch, English, German, and Japanese). Set your preferences to each of the available languages in turn, and click on this link after each change.
Related links, Authoring HTML & CSS
Related links, Set up a Server