verot.net - How to reset Google languages from Firefox search, manipulating the URL
===================================================================================
google_language.htm
### The problem
I am English speaking, and prefer my Google search results to be from
google.com: http://www.google.com rather than google.fr:
http://www.google.fr when from France. But each time I use the Firefox
search box, from a French IP, Google redirects to the French site, and I
mostly end up with French results, when I would prefer english results.
Here is what the search URL looks like when searching from Firefox:
http://www.google.fr/search?q=linux
&ie=utf-8
&oe=utf-8
&aq=t
&rls=com.ubuntu:en-US:official
&client=firefox-a
This leads to French results:
http://www.google.fr/search?q=linux&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:official&client=firefox-a
, in this case the first one being the Wikipedia French page for Linux.
### How to get English results?
Two parameters are related to languages: hl and lr. According to this
Google page: http://code.google.com/apis/soapsearch/reference.html and
this PDF document:
http://www.joostdevalk.nl/dl/wp-content/uploads/2007/07/google-url-parameters.pdf
, hl controls the language for the interface of the Google page, and lr
restricts the results to one or more languages.
So if I add hl=en in the query string, I get the english interface, as well
as English results:
http://www.google.fr/search?q=linux
&ie=utf-8
&oe=utf-8
&aq=t
&rls=com.ubuntu:en-US:official
&client=firefox-a
&hl=en
I then get this results page:
http://www.google.fr/search?q=linux&ie=utf-8&oe=utf-8&hl=en&aq=t&rls=com.ubuntu:en-US:official&client=firefox-a
, the first result being the linux.org site, in English.
Similarly, if I add lr=lang_en in the query string, I get the english
results, but with the interface in local language:
http://www.google.fr/search?q=linux
&ie=utf-8
&oe=utf-8
&aq=t
&rls=com.ubuntu:en-US:official
&client=firefox-a
&lr=lang_en
I get this results page:
http://www.google.fr/search?q=linux&ie=utf-8&oe=utf-8&lr=lang_en&aq=t&rls=com.ubuntu:en-US:official&client=firefox-a
, the first result being the linux.org site, in English.
Weirdly enough. the results are almost the same with either parameters.
Your mileage may vary.
Note that you can use hl and lr together, so to have have English results
with a French interface, or French results with an English interface. Here
are a few tests which show the effect of each of the language settings, and
describe the results that you get from google.fr:
- hl=en: http://www.google.fr/search?q=linux&hl=en : Results and interface
in English, same as google.com
- lr=lang_en: http://www.google.fr/search?q=linux&lr=lang_en : Results in
English, and interface in French
- hl=fr: http://www.google.fr/search?q=linux&hl=fr : Results and interface
in French
- lr=lang_fr: http://www.google.fr/search?q=linux&lr=lang_fr : Results and
interface in French, same as above
- lr=lang_fr&hl=en: http://www.google.fr/search?q=linux&lr=lang_fr&hl=en :
Results in French, and interface in English
- lr=lang_en&hl=fr: http://www.google.fr/search?q=linux&lr=lang_en&hl=fr :
Results in English, and interface in French
### How to do it?
The goal is to change Firefox default query string for Google searches.
According to Mozilla wiki:
http://wiki.mozilla.org/Firefox2/L10n_Requirements , the query string is
created as following:
q=MY+IMPORTANT+SEARCH : Search term
ie=utf-8 : Input encoding
oe=utf-8 : Output encoding
client=firefox-a : Used when Google ships as the default search engine
client=firefox : Used when Google ships as the non-default search engine
rls=org.mozilla:en-US:official : Will vary based on locale
aq=t : Identifies the query as coming from a suggest-enabled searchbox
You can change these parameters, although it is rather hidden into Firefox.
Under Linux, open the following file
/usr/share/firefox/searchplugins/google.xml (it may also be
/usr/lib/firefox-addons/searchplugins/google.xml,
/usr/lib64/firefox-x.x.x/searchplugins/google.xml)
Simply add the following line in the list of parameters:
Or if you prefer to use lr:
I prefer to use hl, which yields best results as far as I am concerned.
However, lr has an important advantage: you can mix languages to retrieve
results from pages in several languages. For instance, you can get English
and German results if you set lr to lang_en|lang_de.
I guess you can also remove the parameters client, rls and aq, but I
wouldn't recommend it. Some people say that the results change when the
search is performed from Firefox search box:
http://www.webstractions.com/news/2004/10/firefox-searchbox-reporting-less.html
, but keep in mind that the Mozilla Fundation receives some money from
Google: http://blogs.zdnet.com/BTL/?p=6715 depending on the searches made
from inside the Firefox search box. So...
### Anything else?
Michael sent me a few more tips.
You can use search plugins to add a word that you search for frequently
together with other words. You can for instance use it to find sites about
local stuff by adding +London.
You can use the setting as_qdr to search for recent pages. For instance, to
get results from the past month only, add:
You'll save yourself a lot of time by adding the following, to give you 40
hits per pages:
If you're savvy about using tabs, you can get every search result to open
in a new tab (I prefer the Tab Mix Plus extension:
https://addons.mozilla.org/en-US/firefox/addon/1122 ):
You can exclude an TLD (or only include it) using as_dt and as_sitesearch
together. To exclude .info TLD, add:
To include only .info TLD, add:
If you have any comments or other tips, email me!: mailto:web@verot.net
Note that this page is for Firefox 2, and that you need to restart Firefox
to have it to work. And each time you'll update Firefox, you will have to
re-apply your changes to the XML file.