note 28542 added to ref.gettext
| From: | Eneko at rack1 dot php dot net | Date: | Thu, 16 Jan 2003 14:20:34 +0000 |
| Subject: | note 28542 added to ref.gettext | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-42216@lists.php.net to get a copy of this message | ||
Some tips from my Red Hat Linux 7.3 system.
It didn't work for me until I set a full locale (i.e. es_ES) with setlocale.
I was trying with Michele Manzato's example (thank you!), but as it sets the language without
the country, it was failing for me. Here is the example "fixed" with full locale:
// Change to script directory
// (Not needed in RH 7.3)
$path = dirname(getenv(PATH_TRANSLATED));
chdir($path);
// Set the language as full locale 'es_ES'
$language = 'es_ES';
putenv("LANG=$language");
setlocale(LC_ALL, $language);
// Set the text domain as 'mydomain'
$domain = 'mydomain';
bindtextdomain("$domain", "./locale");
textdomain("$domain");
// The .mo file searched is:
// ./locale/es_ES/LC_MESSAGES/mydomain.mo
// or if previous one doesn't exist:
// ./locale/es/LC_MESSAGES/mydomain.mo
echo gettext("Hello world!");
Hope this helps!
Eneko.
--
http://www.php.net/manual/en/ref.gettext.php
http://master.php.net/manage/user-notes.php?action=edit+28542
http://master.php.net/manage/user-notes.php?action=delete+28542
http://master.php.net/manage/user-notes.php?action=reject+28542