note 45032 deleted from ref.gettext by didou
| From: | didou@php.net | Date: | Wed, 29 Dec 2004 13:05:49 +0000 |
| Subject: | note 45032 deleted from ref.gettext by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-82455@lists.php.net to get a copy of this message | ||
Note Submitter: info at dci dot dk
----
I found gettext to be a little cumbersome especially because
apparently you have to restart apache everytime you update
your .mo file (which is difficult if you are hosted). If you have
the same problem, I can recommend this solution:
http://www.onlamp.com/pub/a/php/2002/11/28/php_i18n.html
<?php
$messages = array (
'da_DK'=> array(
'My favorite food is' => 'Min livret er',
'french fries' => 'franske kartofler'
)
);
function msg($s) {
global $LANG;
global $messages;
if (isset($messages[$LANG][$s])) {
return $messages[$LANG][$s];
} else {
return $s; // fallback in case the string is not translated
}
}
$LANG ='da_DK';
print msg('My favorite food is').":\n";
print msg('french fries').".\n";
print msg('OK').".\n";
?>
"Min livret er: franske kartofler. OK."
Of course you might have to write your own scripts to
administer the translations, if you have a lot of them, but if
you have a small homepage, you migh be better off with this.