How to add custom Accept-Languages to Chrome for pseudolocalization testing? How to add custom Accept-Languages to Chrome for pseudolocalization testing? google-chrome google-chrome

How to add custom Accept-Languages to Chrome for pseudolocalization testing?


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


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


"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 requestschrome.runtime.onMessage.addListener(function(request, sender) {  chrome.tabs.update(sender.tab.id, {url: request.redirect});  return;});