I have a couple of principles for supporting multiple languages:
1) Load only what's necessary, and
2) Reference using the language code (see http://www.w3.org/TR/REC-html40/stru...g.html#h-8.1.1 ). For example, "en", "fr", "es"
That said, it is generally not necessary to load a translation for every language -- most of the time the primary language of the site visitor suffices. To accomplish this, a modification of the multidimensional array above suffices:
Filename: en.php
PHP Code:
$lang['hello'] = 'Hello';
Filename: fr.php
PHP Code:
$lang['hello'] = 'Bonjour';
Filename: es.php
PHP Code:
$lang['hello'] = 'Hola';
PHP Code:
// User defines what language $language = "en";
require_once($language.'.php'); // Say hello echo $lang['hello'];
In my sites, I generally have multiple pages, so I create a core language file (as shown above) which includes text which shows up on more than 1 page and then a language file for each page which includes the text for that page which is not in the core file. This minimizes the amount of memory necessary to create each page.
__________________
Jeremy Miller
Please login or register to view this content. Registration is FREE
|