mnoGoSearch 3.3.14 reference manual: Full-featured search engine software | ||
---|---|---|
Prev | Chapter 9. Internationalization | Next |
The original instructions in this article
were made by Craig Small
<csmall[at]eye-net[dot]com[dot].au>
.
Some later changes were done by Alexander Barkov
<bar@mnogosearch.org>
.
In case of a multi-lingual search engine it is convenient to display search form and search results using the language according to the user browser preferences. This article describes how to configure a multi-lingual interface for the mnoGoSearch + Apache combination.
The general idea of this method uses the fact that search.cgi opens a template having the same name with the CGI script. For example, if the name of the CGI script is search.en.cgi, then it opens the template file /usr/local/mnogosearch/etc/search.en.htm (assuming that mnoGoSearch /etc directory is /usr/locale/mnogosearch/etc/). Configuring a multi-lingual interface consists of three simple steps.
Installing multiple templates
You need to create multiple search templates (one template for every language you want to support) with file names in the form search.language.htm, where language is a two-letter language abbreviation, for example: en, pl, ru.
You may also want to have the file search.htm (usually a sym-link to search.en.htm) as the default file.
At the end of this step you will have these files in mnoGoSearch /etc directory:
Installing front-ends
Put search.cgi into your Web server CGI directory and setup the symlinks:
Configuring Apache
You also need to make your Apache understand the trick you are doing here to have content negotiation happen, as well as some magic with the indexes. It can be done either in httpd.conf, or in the .htaccess file in the directory you put search.cgi in.AddLanguage en .en AddLanguage pl .pl AddLanguage ru .ru DirectoryIndex search search.cgi Options FollowSymlinks MultiViews
You open your browser and type the URL http://myhost/mydir/search
(no slash at end !!)
Your browser says "I like English (well language negotiation en)"
Apache finds search.en.cgi:
DirectoryIndex gives search, and MultiViews gives en.cgi)
Apache sets the
environment variable SCRIPT_FILENAME
to
mydir/search.en.cgi and executes
search.en.cgi.
search.en.cgi starts
and detects the template name using
SCRIPT_FILENAME
.
So what happens if the user wants, say, German? Note, there is no search.de.cgi! The first bit of DirectoryIndex (i.e. search) fails, so Apache tries the second one, search.cgi and executes it. search.cgi starts and opens the template file search.htm, which is a symlink to search.en.htm. So you'll get the page in English, which is better than a 404 Not Found.
Rarely you may get some language negotiation problems caused by:
Caches (proxy servers) that don't follow the standards
Old versions of browsers that don't follow the standards
Bad browser configuration with weird stuff in language settings.