|Back to mnoGoSearch site||
|mnoGoSearch 3.2.43 reference manual: Full-featured search engine software|
|Prev||Chapter 7. Languages support||Next|
It is often required to allow for different languages, which means different search.htm files depending on what language users have set in their browser.
Please note that configuration issues given below are absolutely the same for both search.php and search.cgi front-ends.
Note: PHP specific issues: the only thing to be done in search.php is a hack in config.inc to change the template file:$template_file= ereg_replace(".php", ".htm", basename(getenv("SCRIPT_FILENAME"))); $template_file = "/etc/somewhere" . $template_file;
Further installation should be done in three steps.
Installing several templates.
The general idea is to have one search.php or search.cgi file and then many search.[language].htm files. You also have a search.htm file (usually a symlink to search.en.htm) as default file.
If the name of the script is search.en.php (or search.en.cgi) then both CGI and PHP front-ends will be looking for /somewhere/etc/search.en.htm assuming that /somewhere/etc/ is /etc/ directory of mnoGoSearch installation.
You would then populate /somewhere/etc/ with all the search.htm files so /somewhere/etc has:
Create a directory and put search.cgi or search.php there (along with the include files if you want, but I fiddle with the php include_path and put them elsewhere).
Then setup the symlinks:
Or in the case of PHP front-end:
Then you need to make Apache understand what weirdness you are doing here. So you need to get negotiation happening and some magic with the indexes. I used .htaccess file but you could stick it in the Apache config itself.
AddLanguage en .en AddLanguage pl .pl AddLanguage ru .ru DirectoryIndex search search.cgi (or search.php) Options FollowSymlinks MultiViews
You 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, MultiViews gives the en.cgi)
The SCRIPT_FILENAME which is used in both search.cgi and search.php is somepath/search.en.cgi
Note: Most other variables will give the wrong result, either search or search.cgi)
Your hack in config.inc means you will use search.en.htm.
So what happens if the user wants, say, German? Well there is no search.de.cgi (search.de.php) so the first bit of DirectoryIndex fails, so it tries the second one, search.php OK, they get the page in English, but it's better than a 404.
This does work, you may need some more Apache fiddling to get negotiation to work because I am testing this on a server that already has it setup, so I may have missed something.
You may get some language negotiation problems caused by:
Dumb caches that don't follow standards
Dumb versions of browsers that don't follow standards
Dumb users fiddling with language settings and putting weird stuff in.
The Apache team is working on some workarounds for most of these, if possible. For a reasonably heavily used website you can expect an email about it once a week or so.