Themes > Multi language sites
It is reasonable to asume that a visitor who uses a Dutch browser would prefer a Dutch translation of your website, a visitor with an English browser would prefer the English version, and so on. When a page is requested from a webserver information is passed from the browser to the website. One piece of information which is passed is the language the browser uses. It is passed in a parameter called 'HTTP_ACCEPT_LANGUAGE.
For a Dutch browser this string would be:
nl-NL,nl;q=0.7,chrome://global/locale/intl.properties;q=0.3
And for an English browser:
en-US,en;q=0.7,chrome://global/locale/intl.properties;q=0.3
We can use this information to select the default language for the site. For this we have to check the first two characters of the string.
Implementation
How do we use this knowledge? Well, first of all you must of course create the various version of your website. How to do this is described on the page wich describes the WebsiteX5 way of doing multilanguage sites. But now you are not limited to the directory names 'lang1', 'lang2' and 'lang3'. You can choose your own directory names.
I suggest you publish ALL your sites in subdirectories under the root of your webserver, also the site in your primary language (the root is the folder where you are directed to when you type in your www.domain.com in a browser). The PHP-file with the language selection is placed in this root with the name 'index.php'. When your visitor types in your web address the php-file is executed and the correct site will be selected.
So for example:
/dutch - the Dutch version
/english - The English version
/french - The French version
/german - The German version
index.php - The php-file with the language selection.
The index.php file
In the above example the php file will look like this:
Download this file (right click and save). Then edit it with Notepad to suit your needs.
For each language you have to add an elsif-branch to the script. Note the use of '==' to compare two values. A common mistake is to use only one '=' (it happens to me)...
Because only the first two characters are used to check the language you wont have to do the same check for other countries where the same language is spoken. For example 'en' includes (amongst other) the Brittish, the Scots, Americans, Canadians, Australians, etc).
In this example when your visitor has a another language (for example Spannish), the default language 'English' is selected.
After you have created your index.php-file you have to upload it to your webserver. For this you have to use an FTP program. For example you can use FileZilla, which is an excellent and free FTP-client.
But which codes do I use?
You can find lists of the different language codes on the Internet. But there's also a very handy add on to Firefox. You can use this tool to switch the language settings (the locale) of you browser with the click of a mouse!
You can use it to find the codes you have to use in your index.php and you can also use it to test your multi-language websites. Just change the language settings to English to open your English site automatically, to French for your French version, and so on...
You can find it on https://addons.mozilla.org/nl/firefox/addon/1333
Sub-Menu: