note 43127 added to ref.gettext
| From: | mikolaj at webgate dot bg | Date: | Thu, 10 Jun 2004 08:54:42 +0000 |
| Subject: | note 43127 added to ref.gettext | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-70849@lists.php.net to get a copy of this message | ||
winXP, PHP 4.3.5 as Apache1.3.29 module
Two hints for Windows users.
I found setting locale is neither sufficient nor nessecery. To get it work I needed to set either
LC_ALL or LANG enviroment variable to my locale. Anyway this value must be proper for setlocale so
it is good to test with it. In my case it was bgr_BGR for bulgarian according to http://www.unicode.org/onlinedat/countries.html
gettext checks for files once and keeps them in cashe. Especially it means that if it doesn't
find your files it won't search again, so restart Apache after any directory changes!!
My minimal working script:
<?php
// translation file: D:\Apache\htdocs\mypage\locale\bgr_BGR\LC_MESSAGES\messages.mo
putenv("LC_ALL=bgr_BGR");
bindtextdomain('messages', 'D:\Apache\htdocs\mypage\locale\\');
echo gettext("Hello");
?>
----
Manual Page -- http://www.php.net/manual/en/ref.gettext.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+43127
Delete -- http://master.php.net/manage/user-notes.php?action=delete+43127&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+43127&report=yes
Search -- http://master.php.net/manage/user-notes.php