42

i am testing pseudo-localization of a web-site.

i can configure Internet Explorer to have custom accept languages:

  1. Click Tools, Internet Options
  2. On the General tab click Languages
  3. In the Language Preferences dialog click Add.
  4. Enter a user-defined language of qps-ploc (i.e. the Pseudo (Base) locale)
  5. Click OK

enter image description here

Now when Internet Explorer issues an http request, the accept languages will lead with qpc-ploc:

GET https://stackoverflow.com/ HTTP/1.1
Accept: application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, */*
Accept-Language: qps-ploc,en-US;q=0.5
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E)
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
Host: stackoverflow.com

How do i perform the same change to Chrome? To Firefox?


Update

It should also be noted that Internet Explorer honors my Windows preferences. My Windows is configured to use Pseudo (Base) qps-ploc locale. By default Internet Explorer uses it.

Google Chrome ignores my Windows preferences, deciding instead to request en-US and en language:

GET https://stackoverflow.com/ HTTP/1.1
Host: stackoverflow.com
Connection: keep-alive
Cache-Control: max-age=0
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.220 Safari/535.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Community
  • 1
  • 1
Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219

3 Answers3

45

In Firefox

Use about:config

enter image description here

enter image description here

(There is a typo in qps-ploc in the screenshots, but you surely get the idea)

In Chrome

(Edit: refer to the comments for ways to avoid Chrome override the setting in new versions.)

Edit the file C:\Users\USERNAME\AppData\Local\Google\Chrome\User Data\Default\Preferences, and add:

{ ...

   "intl": {
      "accept_languages": "qps-ploc,en-us,en"
   },

   ...
}

For example:

enter image description here

enter image description here

Eduardo Molteni
  • 38,786
  • 23
  • 141
  • 206
  • Thanks for the complete answer. Colleague here today needed to enable it in Chrome. And while it's a pain enough that he'll use IE instead - the answer is still complete. – Ian Boyd Dec 29 '11 at 18:42
  • 4
    Note that Chrome should be shut down when you edit the file. It can get overwritten if you don't – ryber Oct 25 '12 at 18:14
  • 2
    Doesn't seem to work in Chrome 24.0.1312.57 m on Windows 7. I closed Chrome, added "vo" as language, saved, re-opened the file to check to see whether the update was saved, ok. Started Chrome and the setting was removed from the file. – Mackaaij Feb 20 '13 at 08:34
  • 2
    After restart Chrome tries to fix the config and removes your Chrome user profile. Chrome 25 , Win 7 64bit – ainokna Feb 24 '13 at 21:11
  • 1
    I have the same issue with Windows 7 64bit. Is it possible to prevent Chrome from replacing my values of accept_languages? – kolobok Mar 27 '13 at 14:40
  • 1
    I needed to sign out from Chrome in order to have ability to change accept_languages from file. (Chrome stores its configuration in sqlite3 local db and I think it loads the same database from Google servers and then compare them (or smth like this)) – kolobok Mar 28 '13 at 20:45
  • We use "vo" to show resourcekeys and "ie" to show developer resources. Changing accept_languages (and I guess all settings) doesn't work when you're logged into Chrome and sync your SETTINGS. You can disable Chrome Settings > Advanced sync setting > Choose specific items to sync and uncheck Settings. Then close all chrome.exe processes via Windows Task Manger (Ctrl+Shift+Esc), edit the file Preferences, and add an accept_language up front. Save the file Preferences and start Google Chrome. There is also a --lang= parameter but that somehow doesn't seem to work for this purpose. – Mackaaij Jan 29 '14 at 20:25
  • 1
    I cannot get this fix to work. I've killed all my Chrome.exe processes in task manager. I've edited Preferences and added zh-XX to accept_languages at the beginning (and end during other tests). Chrome does not overwrite the change. I'm running Chrome Version 42.0.2311.90 m (64-bit). – Scott Leslie Apr 27 '15 at 20:06
  • Regarding the Firefox solution, how can I modify the `relative quality factor q`? – Beko Jul 01 '17 at 20:12
41

You can also set this via the settings page.

Go to settings (cmd + , on mac, probably cntrl + , on windows) and search for language. Click the "manage languages" link and add your preferred language. After that just drag your language to the top of the list and you're done!

The search results and the manage languages link

Or direct access to languages settings: chrome://settings/languages

The languages list

Grigory Kislin
  • 16,647
  • 10
  • 125
  • 197
Allard Stijnman
  • 1,284
  • 11
  • 22
  • 4
    Unfortunately this doesn't work for all languages available in Windows. Chrome only lets you add languages that it, internally, recognizes. But it's a good stop-gap for the more common languages. – Ian Boyd Oct 21 '13 at 15:25
  • 5
    it seems that display language and accept language are two different things – serhio Feb 20 '14 at 22:06
  • @serhio: Except that it is. Somehow (thanks to the translate bar?), Chrome decided I'd rather read overly-sensitive Web 3.0 pages in German (a language I'm far from fluent in) instead of English. This answer was just the thing I needed to reset my `Accept-Language` header from `en-US,en;q=0.8,de-DE;q=0.6,de;q=0.4` to `en-US,en;q=0.8`. – Eric L. Mar 11 '14 at 14:38
  • 1
    или сразу: chrome://settings/languages – Grigory Kislin May 23 '17 at 14:16
1

"intl.accept_languages" did not work on the latest version of Chrome, after go through the code of Advanced Page Language Switcher (https://chrome.google.com/webstore/detail/advanced-page-language-sw/mhgjlbolkmcookadjpolimbddngjgbol). You can change it using chrome.webRequest.onBeforeSendHeaders.addListener.

Some sample code was like the following (copied from the above extension's backgroud.js).

var locale = "",
    ulrLocation = "",
  contentLang = "";

let extraInfoSpec = ["blocking", "requestHeaders"];
if (chrome.webRequest.OnBeforeSendHeadersOptions.hasOwnProperty('EXTRA_HEADERS')) {
  extraInfoSpec.push('extraHeaders');
} 
chrome.webRequest.onBeforeSendHeaders.addListener(function(HEADERS_INFO){
  for (var header of HEADERS_INFO.requestHeaders) {
    if (header.name == "Accept-Language") {
        header.value = locale;
    }
  }

  chrome.tabs.query({ active: true, currentWindow: true }, function(tabs) {
    chrome.tabs.sendMessage(tabs[0].id, {language: locale});
  });

  return {  requestHeaders: HEADERS_INFO.requestHeaders };
},{ urls: ["<all_urls>"] }, extraInfoSpec );

var setLocale = function(x) {
  locale = x;
}
var setCasinoLocation = function(y, z) {
  ulrLocation = y;
  contentLang = z;
}
//Listen for redirect requests
chrome.runtime.onMessage.addListener(function(request, sender) {
  chrome.tabs.update(sender.tab.id, {url: request.redirect});
  return;
});

Donghua Liu
  • 1,776
  • 2
  • 21
  • 30