Google Globetrotting Woes

I am currently on the beautiful island of Cebu in the Philippines visiting with my old friend and colleague Charles Richmond at IISC and giving some talks on OS internals.  I use a Lenovo Thinkpad laptop running Windows Vista Ultimate when travelling with Mozilla Firefox 3 as my default browser.

Firefox 3 comes with a default Search Bar on the top right hand corner containing a number of default search engines including Google. If I type a search term in the Google Search Bar option, Google figures out behind the scenes that I am located in the Philippines, redirects me to www.google.com.ph and displays the search results with the interface language set Filipino (also spelt as Pilipino) as shown here.


This is not too much of a hindrance in the Philippines but becoming a total annoyance when in Japan, China, Vietman and many other countries. The standard workaround for this is to force Google to display its interface language in English by going to Google.com and setting your user preferences to English which results in Google.com creating a cookie on your machine to persist your preferences.

Maybe it is a bit of overkill or paranoia but I have Firefox set up to delete all cookies when terminating a session for the purpose of personal privacy and security. Thus Google defaults back to whatever interface language Google defaults to for the country that Google thinks I am currently in the next time I fire up Firefox and go to Google.com.

One way to overcome this problem is not to use the Firefox search bar but instead to browse to www.google.com/ncr where NCR stands for No Country Redirect before performing any searchs. Rather than going this route, I decided to write my own Search Engine plug-in so that I always get an English interface when I use the Firefox Google search toolbar. It turns out that this is quite easy to do once you understand what is required.

Cut and paste the following code into a file called GoogleEN.xml and save the file.
<SearchPlugin xmlns="http://www.mozilla.org/2006/browser/search/">
<ShortName>GoogleEN</ShortName>
<Description>Google Search (NCR English)</Description>
<InputEncoding>UTF-8</InputEncoding>

<Image width="16" height="16">data:image/x-icon;base64,
AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQA
AAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAACZMwD/mTMA/5kzAP+ZMwD/mTMA/5k
zAP+ZMwD/mTMA/5kzAP+ZMwD/mTMA/5kzAP+Z
MwD/mTMA/5kzAP+ZMwD/mTMA/////////////
/////////////////////////////////////
//////////////////////////mTMA/5kzAP/
////////////////48u//0a2g/71vWP+hLgz/
pCUI/5xDG/+dRRz/pFIs/7ibk//q4+D//////
5kzAP+ZMwD////////////q0MX/pDIP/6gxC/
/kq5H//fj1//////////////////zezv+MHgf
/r5SE//////+ZMwD/mTMA///////36+X/pjAL
/6YwC//Wr5z//////////////////////////
//97eX/jB4G/7ecjP//////mTMA/5kzAP////
//4ZJu/5o5DP/Hm4j////////////////////
///bk2/+gUCv/mD4V/54rCP+vhm7//////5kz
AP+ZMwD///7+/7xPHf+dLAn/+PXz/wAA/////
////////wAA/////fz/AAD///bRv//52Mf/AA
D//wAA//+ZMwD/mTMA//77+f+uNAz/nzcZ///
///8AAP///////wAA//8AAP///////wAA////
////AAD//wAA////////mTMA/5kzAP/++/n/t
FUo/5RAG///////AAD//wAA////////AAD///
////8AAP//AAD//wAA/////////////5kzAP+
ZMwD////+/7xVLv+WPBf//////wAA//8AAP//
/////wAA////////AAD/////////////AAD//
/////+ZMwD/mTMA///////plHP/mDUR//////
8AAP////////////8AAP///////wAA//8AAP/
/AAD//wAA////////mTMA/5kzAP//////8cm8
/607FP+6jn//+Ojl/////////////////////
///////9+7q//b08v///////////5kzAP+ZMw
D////////////yu6X/qD4Z/8eQgP/46OX////
/////////////7Luz/55IIf95JQj/9O3q////
//+ZMwD/mTMA//////////////////PFuP/Pa
Uj/uDUO/7U0Cf+1NAr/tTQJ/6k2Ff/dqJH/8t
DD//79/f//////mTMA/5kzAP/////////////
///////////////38+f/48uz/9e3m//bv6P/7
+PX//////////////////////5kzAP+ZMwD/m
TMA/5kzAP+ZMwD/mTMA/5kzAP+ZMwD/mTMA/5
kzAP+ZMwD/mTMA/5kzAP+ZMwD/mTMA/5kzAP+
ZMwD/AACsQQAArEEAAKxBAACsQQAArEEAAKxB
AACsQQAArEEAAKxBAACsQQAArEEAAKxBAACsQ
QAArEEAAKxBAACsQQ==
</Image>

<Url type="text/html" method="GET"
   template="http://www.google.com/search">
   <Param name="site" value="ncr" />
   <Param name="q" value="{searchTerms}"/>
   <Param name="h1" value="en"/>
   <Param name="oe" value="utf-8"/>
</Url>
<SearchForm>http://www.google.com/ncr</SearchForm>
</SearchPlugin>
I created a custom icon for the GoogleEN plugin by using a free icon editor to create a 16 x16 pixel True Color + Alpha graphic which I saved as an .ico file. I then used another free utility to convert the contents of the .ico file to a base64 string which I pasted into the plugin <image> tag with the appropriate attributes as shown above.

There are a number of ways of adding a custom search plugin to Firefox. The easiest way is probably to use the Firefox extension to add the plugin to the Firefox Search Bar. This will store GoogleEN in your Firefox searchplugins subdirectory. On Windows Vista, this happens to be at
C:\Users\<user>\AppData\Mozilla\\Mozilla\Firefox\Profiles\<profile>\seachplugins\
The image below shows what new custom plugin looks like when it is installed and being displayed on the Search Bar menu.

If you enter a search term in our GoogleEN custom plugin the results are always displayed using an English user interface as shown in the below image.

The concept of a custom search plugin could easily be extended to include a number of custom plugins for Spanish, German or any language you desire now that I have shown you how to create a basic search plugin. I have omitted details such as namespace declarations because they are unnecessary for our simple search plugin

As often happens, after I wrote this custom plugin, I came across the Mozilla MyCroft Project which has a similar No Country Redirect plugin. Another useful source of information that I found is the OpenSearch Plugin specification.

Well thats all for today. Time to go out for dinner and some sight seeing.

0 comments:

Post a Comment