Making i18n work on all Unix webservers ?

From: Date: Mon, 04 Aug 2003 10:25:18 +0000
Subject: Making i18n work on all Unix webservers ?
Groups: php.general 
Request: Send a blank email to php-general+get-158134@lists.php.net to get a copy of this message
With the following code to translate messages in french, we need to put the mo files in a directory like ./local/xxx/LC_MESSAGE/messages.{mo,po} putenv("LANGUAGE=french"); setlocale(LC_ALL, 'fr_BE'); bindtextdomain("messages", "./local"); textdomain("messages"); echo '<br>' . _("Yes"); On one linux webserver, xxx must be 'fr' (and LANGUAGE set). On another linux webserver, xxx must be 'french' (no var to set). How can I guess which xxx to use, for my code to work on any webserver ? Other solution than using 3 or more directories like 'fr', 'french', 'fr_BE', and copying it? In fact, I'd like to make it work on windows servers too... And how can I guess which env var to set (or not) and in which order (LC_ALL, LANG, LANGUAGE, ...) ? Is there a way to do it for the code to work nearly everywhere ? I'll use a class to hide that complexity. Can someone help ? The PHP documentation is far from beeing clear and precise enough in that particular field. --- Christophe Chisogne Developper, Publicityweb sprl http://www.publicityweb.com

« previous php.general (#158134) next »