note 29790 added to ref.gettext
| From: | robert at klugher dot com | Date: | Tue, 25 Feb 2003 11:24:36 +0000 |
| Subject: | note 29790 added to ref.gettext | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-44493@lists.php.net to get a copy of this message | ||
One trick I found after HOURS of tries :
when you use the setlocale(), PHP will use the locale info it will find in, for example,
/usr/share/locale to set the language info for LC_ALL, LC_MESSAGES, ...
You can check the exact info it will use by using putenv() with LANG=.... and looking at the return
value of setlocale(LC_ALL, ""). The language value your gettext function will use to look
for your translation file is the one given for LC_MESSAGES.
Example :
I was setting the LANG as fr_BE, and placed the translation file in
dirxxx/locale/fr_BE/LC_MESSAGES/...
As it was locale info in my system for fr_BE but NOT LC_MESSAGES, PHP choosed to use the LC_MESSAGES
settings for fr_FR instead and then, was looking for a translation file in
dirxxx/locale/fr_FR/LC_MESSAGES/..., which wasn't found of course.
So, just make sure to look at the return value of setlocale to see what language value is associated
to LC_MESSAGES and, then, to know in which subdirectory the translation file will be looked for by
gettext.
Robert
--
http://www.php.net/manual/en/ref.gettext.php
http://master.php.net/manage/user-notes.php?action=edit+29790
http://master.php.net/manage/user-notes.php?action=delete+29790
http://master.php.net/manage/user-notes.php?action=reject+29790