In a growing world environment of business and commerce, the need to reach customers internationally has proven to be even more prevalent than before. Even though many countries teach English, the need to have multiple language support on your web sites is ever increasing.
Fortunately, Apache Web Server has a module that can handle your need for this support. That’s where mod_mime comes in. It’s built in to SLES 10′s Apache Web Server package, mainly because it also handles many different file types, but language support is another part of it. The cool part is that you can make it completely invisible to the user.
One thing this article or mod_mime does not do is actually translate your web pages between different languages. That would be sweet. There are applications and services that will translate your documents, although most of them leave something to be desired. I speak German also and have tried several with simple German statements and the translation is at best, close, but left out what the actual translation to English is. The best way is to have someone who speaks the target language and have them manually translate your documents.
The steps for setting up Apache Web Server to allow for multiple languages are as follows:
Apache Web Server on SLES 10 comes with the modules for multiple language support already added to the package and already added to the configuration. All we have to do is add any additional languages that we want to support.
First, a little bit about module mod_mime. Mod_mime is responsible for determining behavior based on file type. An example would be, if the file name is picture.gif, then mod_mime associates the behavior as defined in MIME/type image/gif. If the file name is index.html, then mod_mime associates the behavior as defined in MIME/type text/html. Mod_mime accepts multiple extensions, such as index.de.html and assigns them accordingly. In fact, order is also irrelevant, mod_mime handles index.html.de the same way. Where this can be confusing, is if you have a file named index.gif.html, since two different types of MIME/types are specified, mod_mime will select the type farthest to the right. So, index.gif.html would be associated to MIME/type text/html.
Most sources I read on this subject reference, creating a separate .htaccess file and putting your Apache directives for language in this file. the problem is, if you don’t put this .htaccess file high enough in your Document Root directory tree, you’ll come up short with supporting languages in other areas of your web site, and will have to add this file to all associated sites.
My recommendation is to put these directives in with the basic Apache configuration so it is defined globally and once. Making it easier to maintain and, if needed, to add more languages at a later date.
So, with your favorite vi editor, edit the file /etc/apache2/default-server.conf
Scroll down to the comment Configure the DocumentRoot make the following modifications in Bold
# Options None
AddLanguage de de
AddLanguage en en
LanguagePriority de en
If you need to add addition languages, you can add more “AddLanguage” directives. Here is a good list of the current set is and their codes.
Save the file and restart Apache with the following command
Here we are just going to add additional languages to our own browsers so we can see the results of our testing.
If you use FireFox, as any good Linux user would, click Edit | Preferences
Click the Advanced and General Tabs. At the bottom, you will see a button for Languages, click Choose
You’ll see the list of languages that you currently use and their codes. At the bottom, you can add additional languages and select them from the list.
Remember the first language listed is the Default. If you want to change this, you must change the order.
I chose German (de) for my testing.
I’ve created two web documents to show supported languages in the browser and how they are identical except for the language they are written.
index.html.en – English
index.html.de – German
I place these documents in the /srv/www/htdocs/ or my Document Root.
To test is very simple, Set your preferred language in your bowser and type in the site URL.
Now, change your language preference to German and refresh your browser window.
Wunderbar! That looks pretty sweet to me!
This is a simple, yet effective example of how you can add additional language support for your web sites. Be sure to change any images with text on them to reflect your additional languages also. Have fun!