Localizing Apache and Mozilla
Author: Arun Sharma
Date: Dec 15, 2001
This document attempts to help those of you who want to setup a language
preference in your browser, so that when you visit a server, which offers
the content in multiple languages, you get the content in your preferred
language.
Settiing up the Apache web server
First add the following lines to your httpd.conf
$ egrep Language.*\(hi\|kn\) /etc/httpd/conf/commonhttpd.conf
AddLanguage kn-in .kn_IN
AddLanguage hi-in .hi_IN
Now, create content as follows:
$ ls -l /var/www/html/bsd-india/bsd-india*
-rw-r--r-- 1 root root 2247 Dec 16 15:45 /var/www/html/bsd-india/bsd-india.en.html
-rw-r--r-- 1 root root 3510 Dec 16 15:45 /var/www/html/bsd-india/bsd-india.hi_IN.utf8.html
lrwxrwxrwx 1 root root 17 Dec 15 16:30 /var/www/html/bsd-india/bsd-india.html -> bsd-india.en.html
-rw-r--r-- 1 root root 3776 Dec 15 16:13 /var/www/html/bsd-india/bsd-india.kn_IN.utf8.html
Restart the webserver and test that everything is working, as
follows:
$ wget --header="Accept-language: hi" http://www.sharma-home.net/bsd-india/bsd-india
$ wget --header="Accept-language: kn" http://www.sharma-home.net/bsd-india/bsd-india
and you should get the content in the right language. Further,
you should add the correct META tag to your HTML documents, so that a robot
can classify it as a document written in a specific language. Example:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>BSD India</title>
<meta http-equiv="content-type" content="text/html; charset=utf8">
<meta http-equiv="content-language" content="hi-IN">
</head>
The language tag should be from
ISO 639 and the subtag is typically the country (
IANA assigned). Last but not the least, use the URI without the suffix,
so that content negotiation is possible. In other words, use
http://www.sharma-home.net/bsd-india/bsd-india
and not
http://www.sharma-home.net/bsd-india/bsd-india.html
Setting up Mozilla
At the basic level, you want to make sure that the browser sends out the
right "Accept-language" and "Accept-Charset" headers. In Mozilla, you
can do this by navigating to:
Edit -> Preferences -> Navigator -> Languages
and adding your preferred languages. Examples are "hi-in" (Hindi) and "kn-in"
(Kannada).
The recommended encoding for Indian languages is UTF-8.
Setting up IE
In Microsoft Internet explorer, you can do this by navigating to:
Tools -> Internet Options -> Languages