note 45032 added to ref.gettext

From: Date: Mon, 23 Aug 2004 22:25:36 +0000
Subject: note 45032 added to ref.gettext
Groups: php.notes 
Request: Send a blank email to php-notes+get-75184@lists.php.net to get a copy of this message
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. ---- Manual Page -- http://www.php.net/manual/en/ref.gettext.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+45032 Delete -- http://master.php.net/manage/user-notes.php?action=delete+45032&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+45032&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#75184) next »