As with any good HTML
browser, it is possible to read what language the WAP device is configured for, depending
on whether it includes this in the HTTP headers it sends to the webserver. Most devices
do, so this variable can be read and text can be localized based on this.
The HTTP header is called Accept-Language and contains one or more
language identifiers separated by a comma. Each identifier is a two character code, based
on ISO-639, for instance en for english, no for
Norwegian and so on. For a complete list of language codes, see this ISO-639
document.
The following bit of PHP code shows the
way to read the Accept-Language header and select the language. The code
should be easy enough to convert to other script languages. The basic concept is to read
the two first characters from the Accept-Language header and simply
choose the language based on that.
<wml>
<card id="loc" title="Localized Text">
<p>
<?
switch(substr($HTTP_ACCEPT_LANGUAGE,0,2)) {
case "en":
echo("Your WAP device is configured for English language");
break;
case "no":
echo("Din WAP-dings er konfigurert for Norsk språk");
break;
case "sv":
echo("Din WAP-sak är konfigurerad för Svensk språk");
break;
default:
echo("I have no idea what language your WAP device is using..");
}
?>
</p>
</card>
</wml>
|
|