SUSE Conversations


Configuring Apache for Multiple Language Support on SLES 10

mfaris01

By: mfaris01

May 8, 2008 1:44 pm

Reads:440

Comments:0

Rating:0

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:

Server Configuration

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

<Directory “/srv/www/htdocs”>
# Options None

Options +MultiViews
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.

http://www.loc.gov/standards/iso639-2/php/code_list.php

Save the file and restart Apache with the following command

rcnovell-apache2 restart

Browser Configuration

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.

Document Creation

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.

Testing

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!

Conclusion

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!

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)

Tags:
Categories: SUSE Linux Enterprise Server, Technical Solutions

Disclaimer: As with everything else at SUSE Conversations, this content is definitely not supported by SUSE (so don't even think of calling Support if you try something and it blows up).  It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test, test, test before you do anything drastic with it.

Comment

RSS