[geeklog-devel] Question about internationalization and look-ups

Joe Mucchiello joe at ThrowingDice.com
Sun Feb 17 10:10:44 EST 2008

At 04:10 AM 2/17/2008, Michael Jervis wrote:
>Then each module has it's translation file (homePage.en.php for example):
>$_LANGUAGE = array_merge($_LANGUAGE, array(
>     'homepagewelcome' => 'Welcome to Snakenet',
>     'TuneInBlock' => 'Tune In'

So what happens when 2 different modules use the same key for two 
different meanings? In essence, your solution is the same as the GL1 
solution but GL1 at least avoids potential collisions better. In 
fact, there are only two flaws with the GL1 solution and neither is 
hard to overcome:
1) Early implementations used numeric indexes instead of contextual 
text indexes.
2) By tradition, no default language file is loaded first.

Refactoring GL1 to solve these two problems would not be hard, just tedious.

>Either way, it's a pain in the arse to keep your translations in
>synch, but, at least with My Way you always get a default string
>(typically in English).

Actually, your method suffers the same problem as GL1. You either 
load a specific language file or the english file. So if the 
alternate language file is out of sync, you potentially have missing 
text. Makes more sense to do this (both in GL1 and your translate class):

include_once $_CONF['path_language'] . 'english.php';
if ($lang != 'english') { // in GL1 also check $lang != 'english_utf8'
     @include_once $_CONF['path_language'] . $lang . '.php';

Of course, the new caching template library adds another dimension to 
this. Static page text can be placed right in the template files and 
the cache file is language dependent. So if you have a template like this:
-- greeting.thtml
<div class="greeting">{$LANG_GREETING['welcome']}, {username}</div>
The English cached version is
<div class="greeting">Welcome, <?php echo $this->val_echo('username'); ?></div>

while the French cached version might be (I'm no expert in French):
<div class="greeting">Bienvenu, <?php echo 
$this->val_echo('username'); ?></div>

Joe Mucchiello
Throwing Dice Games

More information about the geeklog-devel mailing list