Log in

View Full Version : TUTORIAL: Changing the language Web pages are requested by PPC Web browsers


Menneisyys
08-23-2006, 06:18 PM
Can I change the language a given Web page is requested by my Web browser on my Pocket PC?

I’ve just received a question from one of my blog readers (http://www.pocketpcmag.com/blogs/index.php?blog=3&p=464&more=1&c=1&tb=1&pb=1) about how the built-in Web browser in the Pocket PC / Windows Mobile operating system, Pocket Internet Explorer (PIE) / Internet Explorer Mobile (IEM) can be configured to request pages in different language than US English if you use an English language Windows Mobile operating system.

As this question is a very interesting one and very few people have the necessary HTTP- and actual programming (let alone offering a proxy server for free that does the trick!)-level knowledge to answer this question, I’ve decided to write a complete article on it.

What's the point? When can this be useful?

There are a lot of Web sites that offer their content not only in English but also in several other languages. The most important example is Google or, for example, many blogging engines. For example, b2evolution(the engine used in the Smartphone & Pocket PC Magazine Expert Blogs (http://www.pocketpcmag.com/blogs/)) returns English pages by default. However, if you configure your local Web browser to request Web pages in another language, you'll receive Web content in that language.

For example, if you set your referred language to, say, Finnish, you'll get this (Finnish language) page (http://www.winmobiletech.com/kuvat/b2evoFinnishLogin.bmp.png) instead of this (http://www.winmobiletech.com/kuvat/b2evoEngLogin.bmp.png) (English original) when you try to log in. And, the list continues - there are a LOT of other pages, frameworks, content management systems that do take into account what language the client prefers and return their Web content accordingly.

Making use of this capability can be of enormous advantage for people that don’t really have a good command of English and would like to prefer content or, at least, menus and dialogs in their native tongue.



How can you instruct desktop Web browsers to request Web pages in the language of my choice?

With Internet Explorer, go to Tools/Internet Options/ General and click Languages in the Appearance group (http://www.winmobiletech.com/kuvat/DesktopIELangChange-1.png). Then, just click the Add button (http://www.winmobiletech.com/kuvat/DesktopIELangChange-2.png) and choose the language you prefer from the list (http://www.winmobiletech.com/kuvat/DesktopIELangChange-3.png). Make sure you move it up the list (with the Move Up button (http://www.winmobiletech.com/kuvat/DesktopIELangChange-4.png)) so that it'll be your primary language.

As far as the desktop Opera browser is concerned, I'll elaborate on it later.

The desktop Mozilla/Firefox must be configured in exactly the same way as the Pocket PC version (screenshot (http://www.winmobiletech.com/kuvat/DesktopMozillaLangCh.png)) - see below.

OK; now, how I configure my Pocket PC Web browsers to do the same?

It's, unfortunately, a bit more complicated. Read on!

A bit geeky stuff: HTTP and Accept-Language

(Note that understanding this section is not needed if you aren't a tech / geek type of person. However, trying to digest it can be very useful to understand my HTTP request header screenshots and to understand how, for example, my proxy servers work.)

First, to understand how the HTTP servers (that is, Web servers) are able to decide in which language they should return the requested Web page, it's very important to know that the HTTP protocol (the protocol used in communicating between a Web server and a browser) uses so-called 'HTTP request headers'. These requests tell the Web server what resource to get, whether it's cached on the client (so that the server only needs to return the resource again if it's been changed in the meantime), whether the client has 'cookies' stored about the server to maintain Web sessions and so on.

One of these headers is called 'Accept-Language' and tells the Web server what language the client prefers (with, optionally, an additional country code and/or quality setting when there is a list of preferred languages). For example, if you'd prefer pages in Finnish instead of the default English, this header looks like the following:

Accept-Language: fi (or, Accept-Language: fi-FI - both are valid and can be used. The first, lowercase 'fi' stands for Finnish, the second, uppercase 'FI' stands for Finland. Note that, in general, the country code can also be lowercase; from now, on, I use lowercase letters to denote the country.)

If you'd prefer your preferred language to be Canadian French, you can use the following request header:

Accept-Language: fr-ca

And, as far as strictly US English is concerned, you'll often see this header:

Accept-Language: en-us

In order to be able to return a Web page tailored for your language preferences, the Web server MUST receive every HTTP request (Web page download) containing the Accept-Language header. If it doesn't receive it, it will in no way know what is your preferred language and will, in almost all cases, return the default one (English in most cases).

Does the system-wide Regional Settings have any effect on the preferred language?

Unfortunately, modifying the regional setting in Settings/System/Regional Settings doesn’t change the “Accept-Language” HTTP header sent out to the Web server (it’s based on this HTTP request header that most HTTP servers – except for Google, which uses a bit more sophisticated algorithm, which I’ll elaborate on later –, if they have content in more than one language, decide what language they should return their content in) – not even in the latest WM5 AKU2, as can also be seen in this screenshot (http://www.winmobiletech.com/kuvat/AcceptLangNotModdedWithAreaSet.bmp.png). I took the screenshot on a Dell Axim x51v with the latest, AKU2 A12 ROM, after setting the regional setting to Germany (and rebooting). It certainly shows IEM sends out requests telling the Web server that it prefers U.S. English pages, no matter what the operating system setting is.

PIE AcceptLanguage in the Registry

Fortunately, WM2003SE+ IEM/PIE does store the language code in the Registry (and it, even more importantly, does use it) under HKEY_CURRENT_USER\ Software\ Microsoft\ Internet Explorer\ International\ AcceptLanguage. How it is accessed under different operating systems, however, is varying.

First, under Pocket PC 2000 (the first Pocket PC operating system version), there is no International key at all as can also be seen in here (http://www.winmobiletech.com/kuvat/PPC2kPIENoInternational.bmp.png). That is, it’s futile to create the above value in the Registry – it just won’t work.

Under Pocket PC 2002 and WM2003, this value does exist with the value “en-us” for devices with the (American) English ROM. These operating systems, however, do not take this value into account and don’t send out any Accept-Language header as can also be seen in this (http://www.winmobiletech.com/kuvat/PPC2k2NoEffectOfAcceptLang.bmp.png) and this (http://www.winmobiletech.com/kuvat/WM2003NoAcceptLang.bmp.png) screenshots for PPC2k2/WM2003, respectively.

It’s only with WM2003SE+ operating systems (WM2003SE and WM5) that PIE copies the value of this string value to the HTTP request. However, interestingly, on English devices, the value, by default, doesn’t exist (unlike on Pocket PC 2002 / WM2003 devices, where, much as it does exist, its value isn’t used in the communication with HTTP servers in any way) – this is why I, at first, didn’t realize it’s there and usable. (I've tested this on four different WM5 devices (x51v, hx4700, Wizard, Universal) and on the WM2003SE PL720. None of them had this value, unlike, again, my Pocket PC 2002 Compaq iPAQ 3660 / WM2003 HP iPAQ 2210.)

(Note that there are two other places of the registry having PIE/IEM-related information: HKEY_LOCAL_MACHINE\ SOFTWARE\Microsoft\Windows\ CurrentVersion\ Internet Settings and HKEY_LOCAL_MACHINE\ SOFTWARE\ Microsoft\ Internet Explorer. There, however, is no language-specific information in there.)

All in all, if you have a WM2003SE+ Pocket PC, you can just create a String value named “AcceptLanguage” under the HKEY_CURRENT_USER\ Software\ Microsoft\ Internet Explorer\ International key with the correct language code (with, when needed, also the country code if it’s necessary).

If you don’t want to create the value by hand, I’ve created a registry import file to do the job for you. It’s available HERE (http://www.winmobiletech.com/sekalaiset/AcceptLanguageCreate.reg). All you’ll need to do is importing it with a Regedit5-compatible registry editor like Resco Registry Editor (please also see this roundup of registry editors (http://www.pocketpcmag.com/blogs/menneisyys/UltimateRoundupOfRegistryEditors.asp) for alternates / converting the file to REGEDIT4 format to be able to import with REGEDIT4-only registry editors like Kilmist and Tascal.) Don’t forget to change ‘en-us’ to your language first (for example, ‘ru’, ‘fi’, ‘fr’ etc.) Also, you may want to use some kind of associated quality value as is defined in section 14.4 of the official HTTP 1.1 header specification (http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). (For example, to express "I prefer Danish the most, but will accept (preferably) British English and, finally, other types of English", use the string “da, en-gb;q=0.8, en;q=0.7”)

Do PIE/IEM plug-ins let for changing the language?

Unfortunately, PIE/IEM plug-ins like PIEPlus (http://www.pocketpcmag.com/blogs/index.php?blog=3&p=1170&more=1&c=1&tb=1&pb=1), MultiIE (http://www.pocketpcmag.com/blogs/index.php?blog=3&p=1030&more=1&c=1&tb=1&pb=1) or Spb Pocket Plus (http://www.pocketpcthoughts.com/forums/viewtopic.php?p=366634) (click the links for the latest reviews!) don’t let the user directly supply this vaue – ypu’ll need to directly modify the Registry in order to configure this value.

What about NetFront?

As far as alternate browsers are concerned, NetFront 3.3 sends out the ‘en’ language code by default (http://www.winmobiletech.com/kuvat/NF33NoRegional.bmp.png) . While it is supposed to have support for changing the request language, it, as with many other NetFront features, is buggy.

In order to test this yourself, you'll need to create a new User-Agent entry in (Menu/)Tools / Browser Settings / Misc (as the default entry can’t be modified). There, choose an empty (or, if you've already defined an alternate User-Agent setting, anything different from the default "NetFront v3.3 Standard" custom setting. In this screenshot (http://www.winmobiletech.com/kuvat/NF33CreateNewUserAgentEntry1.bmp.png), I show an example of selecting an empty entry - you'll see this before creating any new User-Agent record. After this, just click the Edit button on the right (http://www.winmobiletech.com/kuvat/NF33CreateNewUserAgentEntry2.bmp.png), give the new setting a new name (in the top "Title" textfield; in this example screenshot (http://www.winmobiletech.com/kuvat/NF33CreateNewUserAgentEntry3.bmp.png), I've called it "Finnish NetFront") and, in the bottom-most "language" input field, enter the language code (in this screenshot (http://www.winmobiletech.com/kuvat/NF33CreateNewUserAgentEntry4.bmp.png), "fi"). Now, click OK; the new entry will be selected as can be seen in here (http://www.winmobiletech.com/kuvat/NF33CreateNewUserAgentEntry5.bmp.png). Now, you can give the new settings a try; as can be seen in here (http://www.winmobiletech.com/kuvat/NF33AcceptLanguageCantBeOverridden.bmp.png), the language code sent out is still the default 'en'. (Note that in this example I've also changed the User-Agent to 'My custom Accept-Language tester User-Agent to show what U-A is sent out' from the default 'Mozilla/4.08 (PDA; NF33PPC3AR/1.0) NetFront/3.3' so that we can see Netfront indeed sends out the modified header.)

Note that NetFront has a “Base language” setting in View/Advanced Setting (http://www.winmobiletech.com/kuvat/NF33BaseLanguage.bmp.png). The setting (which can’t be fine-tuned; for example, North-European languages are only a group and not individual languages), has no effect on anything (it only tells the browser the default encoding it should use when trying to render the page brought back) either.

What about Opera Mobile?

Opera 8.6 (http://www.winmobiletech.com/kuvat/Opera86NoAcceptLangHeaderAtAll.bmp.png) doesn’t send out any Accept-Language header at all (click the links to see the screenshots showing this!).

Note that, on the desktop, Opera supports this (http://www.winmobiletech.com/kuvat/oPERAdESKTOPSupportsAccLang.png) and it can even be freely redefined in the GUI (http://www.winmobiletech.com/kuvat/oPERAdESKTOPSupportsAccLang2.png). I’ve checked the desktop INI files to see whether it’s there that this information is stored (many desktop-based configuration options are also accepted and interpreted by the Pocket PC version of Opera Mobile). Unfortunately, that’s not the case.

NetFront and Opera Mobile – a summary


All in all,

unfortunately, as of their current versions (8.6 of Opera and 3.3 for NetFront) neither of these browsers look up/use the value of HKEY_CURRENT_USER\ Software\ Microsoft\ Internet Explorer\ International\ AcceptLanguage

you can’t configure them either to do so: the built-in request language feature in NetFront doesn't work

In a later section, I'll elaborate on how you can still add/modify an/the Accept-Language header when using these two apps.

What about Thunderhawk?

Thunderhawk (http://www.bitstream.com/wireless/products/pocketpc/index.html) also sends out the english-by-default header (http://www.winmobiletech.com/kuvat/ThunderhawkLangCode.bmp.png). Unfortunately, it can't be modified in the Settings dialog (http://www.winmobiletech.com/kuvat/ThunderhawkLangCode2.bmp.png), it doesn't take into account the PIE/IEM registry setting and, as Thunderhawk doesn't let you use proxy servers, you can't use external proxy servers either to modify this header. This means it's fully impossible to change the language preferences using Thunderhawk, as opposed to all the other browsers.

What about Minimo?

The (as of writing) latest (08-27-2006) Minimo (http://www.mozilla.org/projects/minimo/) nighly build (http://ftp.mozilla.org/pub/mozilla.org/minimo/nightly/2006-08-27-08-MOZILLA_1_8/) offers seamless Accept-Language definition capabilities.

While it doesn't use the PIE/IEM registry value for overriding its setting (http://www.winmobiletech.com/kuvat/Minimo0827-NoOverride.bmp.png), you can easily modify the header. To do this, enter the “about:config” URL in the address bar. You’ll be taken into the preference list screen. There, just enter ‘lang’ in the Filter field and, then, you’ll be taken right away to the intl.accept_languages property as can also be seen in this screenshot (http://www.winmobiletech.com/kuvat/Minimo0827-Config-Lang1.bmp.png). Double-click intl.accept_languages and edit the value (http://www.winmobiletech.com/kuvat/Minimo0827-Config-Lang2.bmp.png) as you find it OK and press Enter. Then, in the config list, “default” will change to ‘user (http://www.winmobiletech.com/kuvat/Minimo0827-Config-Lang3.bmp.png)’ and the headers will indeed be correctly sent out (http://www.winmobiletech.com/kuvat/Minimo0827-Config-Lang4.bmp.png).

Paragon Language Extender (http://pocket-pc.penreader.com/index.html)

Paragon Language Extender is a well-known language changer application (including HTTP request modifying capabilities) for all Pocket PC (and Handheld / Palm-size) operating systems prior to WM5 (there is no WM5 version and never ever try to install the Language Extender on a WM5 device – I’ve tested it on the WM5 Dell Axim x51v; I had to hard reset).

Among other things, WM2003+ versions of the Paragon Language Extender also support dynamic language change as can be seen for example in here:

http://www.winmobiletech.com/kuvat/LanguageExtenderCompact.bmp.png

In this case, ‘de’ denotes I’ve installed the German extender; the screenshot also shows it has its own German-language dictionary.

Interestingly, the Paragon Extender doesn’t create HKEY_CURRENT_USER\ Software\ Microsoft\ Internet Explorer\ International\ AcceptLanguage. It does “sit on” the operating system and inserts its own Accept-Language header into the outgoing PIE requests. (Note that if you do create HKEY_CURRENT_USER\ Software\ Microsoft\ Internet Explorer\ International\ AcceptLanguage by hand, it’ll override that of Paragon (http://www.winmobiletech.com/kuvat/WM2003SEOverrideParagonExtender.bmp.png)).

Note that there are two major versions of Paragon Lang. Extender: and old, PPC2k/PPC2k2-compatible, 4.23 version still available for non-major languages (that is, not available for, say, German or French but available for, say, Finnish, Bulgarian or Arabic) and a new, WM2003/WM2003SE version (the latter is build 4710 for for example Finnish). Unfortunately, the former does NOT make the PPC2k2 PIE send out the correct header. That is, it’s not possible to make the Pocket PC 2002 PIE to send out the correct request with either using Paragon Lang. Extender or, as we’ve already seen, by directly overwriting HKEY_CURRENT_USER\ Software\ Microsoft\ Internet Explorer\ International\ AcceptLanguage.

Finally, in WM2003SE, the Paragon app is not recommended over the “traditional” way of overwriting HKEY_CURRENT_USER\ Software\ Microsoft\ Internet Explorer\ International\ AcceptLanguage – it's an overkill and I only recommend it for “plain” request language modification if you need its other capabilities too.

Note that if you don’t need your device to be fully translated, you won’t need to install the full version – the second, Compact setup (as can also be seen in here (http://www.winmobiletech.com/sekalaiset/LandExtenderCompact.png)) will do just fine. The results after the setup will be as follows:

What can I do if I want to browse the Web with a Pocket PC 2002 / WM2003 PIE or with Opera Mobile / NetFront?

You have two choices.


if you have the capability of running a proxy server somewhere (even on your Pocket PC PDA with a suitable Java Virtual Machine (please read this article (http://www.pocketpcthoughts.com/forums/viewtopic.php?t=41081) and search my blog for the word 'Java' for more info) - after all, it's multiplatform); for example, on a 24/7 online desktop PC,



with a client that can be configured to use an external HTTP proxy (in this regard, Thunderhawk is disqualified) and does send out the Accept-Language header (in this case, NetFront), you'll need to use an external proxy server to change the language code sent out to another one before sending the request further, to the target Web server. If you have a Java Virtual Machine (easily downloadable from here (http://java.sun.com/javase/downloads/index.jsp) - select 'Java Runtime Environment (JRE) 5.0 Update X'), I’ve written an easily modifiable, open-source (source here (http://www.winmobiletech.com/sekalaiset/HTTPProxyAcceptsLangHeaderRewrite.java)) HTTP proxy server available here (http://www.winmobiletech.com/sekalaiset/HTTPProxyAcceptsLangHeaderRewrite.class). You will only need to start it with the command

java HTTPProxyAcceptsLangHeaderRewrite portnumber languagecode

if you have a JRE (I’ve compiled the class with JDK 1.3, so, any JRE will do) installed on your PC (again, you can get it at the above-linked Sun page).

For example, the command

java HTTPProxyAcceptsLangHeaderRewrite 8080 cool-eh

will result in the following response from http://www.proxydetect.com/ (after you correctly set up your Pocket Internet Explorer / NetFront browser to use the proxy - please see for example this article (http://pocketpcmag.com/blogs/menneisyys/ConfigureToonel54.asp) on doing so):

http://www.winmobiletech.com/sekalaiset/AcceptLanguageRewriteCooleh.bmp.png

This shows that indeed the (of course non-existing) ‘cool-eh’ language code was sent to the server.

If you, on the other hand, have a proxy-configurable client that does not send out the Accept-Language header (the case with PPC2k2 PIE and Opera Mobile), you’ll need to explicitly add the header to the headers relayed to the HTTP server. To do so, you'll need this Java class file (http://www.winmobiletech.com/sekalaiset/HTTPProxyAcceptsLangHeaderAdd.class) (source here (http://www.winmobiletech.com/sekalaiset/HTTPProxyAcceptsLangHeaderAdd.java)). Its usage is exactly the same as with the previous bullet.

The results of using this header-adding proxy server can be seen for example here (http://www.winmobiletech.com/kuvat/Opera86WithAccLangHeaderAdd.bmp.png) (showing Opera Mobile).


Mail the webmaster of the given webpage to do a dynamic country lookup depending on the client’s IP (internet) address instead of the Accept-Language header. Say, if you have a Thai client IP address, you would receive a page with Thai content even if your Web client sent out an Accept-Language header of ‘en-us’ (or no language code at all). Many Web sites do so – for example, even Google. Google, if it doesn't receive an Accept-Language header or the header (if it does exist) is the standard one requesting English pages, then, just looks up the country of the client and returns the content accordingly, in the local language of the country. If the Accept-Language header exists and it's set to something other than English, it'll return the page in that local(ized) language. This is what Web server administrators should strive for.



What about devices with non-English ROM's? If I, say, dump / sell my English Pocket PC and get a German one, will I get German pages instead of English ones?

Note that I wasn’t able to reliably test how and what Accept-Language headers the Web browsers on a Pocket PC with a non-English ROM send out. I don’t think the built-in PIE would request English pages on a Pocket PC with a German language ROM, but I may be mistaken (after all, PIE / IEM isn't the most sophisticated Web browser). The same (I don't know how it behaves on devices with non-English ROM's) stands for NetFront, which does send out the language header. Finally, as far as Opera Mobile is concerned, I seriously doubt it’d send out the correct header on any (non-English) Pocket PC – after all, it doesn’t seem to be sending out any kind of language header. (Incidentally, it has the ‘Accept-Language’ string once in opera.dll but there doesn’t seem to be any parameter to it.)

Acknowledgements

My blog reader ‘Begemot’ from Russia (http://www.pocketpcmag.com/blogs/index.php?blog=3&p=1172&more=1&c=1&tb=1&pb=1) to point out the never-anywhere (give for example searching for “AcceptLanguage” a try on major PPC boards like PPCT, Brighthand, AximSite, XDA-Developers (and on Google) etc. Note that, on the latter, there will be some (false) hits because of the MMS handler app on WM PE devices) discussed (this is why I didn’t know of it before either – and, as the given AcceptLanguage value only exist under PPC2k2 / WM2003, I haven’t run into it in the Registry either) HKEY_CURRENT_USER\ Software\ Microsoft\ Internet Explorer\ International\ AcceptLanguage. Without him, I wouldn’t have been able to write this tutorial in its present form. Thumbs up :)

Menneisyys
08-27-2006, 02:18 PM
Article greatly updated, thanks to my Russian reader ‘Begemot’.

Menneisyys
08-28-2006, 09:03 AM
Further updated the article:
1. added info on all desktop browsers, Minimo and Thunderhawk
2. added a much more thorough and comprehensive introduction section so that you can understand the advantages of all this
3. added a version of my HTTP proxy server to help Opera Mobile and Pocket PC 2002 users

Menneisyys
10-28-2006, 08:46 AM
The Netfront-related part of the article updated – along with a new Netfront bug I’ve just found. I’ve also slightly modified the PIE-related part with new, WM2003-related info.