note 93454 added to function.gettext
| From: | mario dot ugedo at gmail dot com | Date: | Thu, 10 Sep 2009 15:03:27 +0000 |
| Subject: | note 93454 added to function.gettext | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-160414@lists.php.net to get a copy of this message | ||
REPLACE NOTE http://es2.php.net/manual/en/function.gettext.php#93407
It's very important call a bind_textdomain_codeset(..) function.
Linux localhost 2.6.28-14-generic
Apache/2.2.11 (Ubuntu) PHP/5.2.6-3ubuntu4.2
<?php
// Set language to Spanish
//setlocale(LC_ALL, 'es_ES'); // es_ES not in the server
setlocale(LC_MESSAGES, 'es_ES.utf8');
// run ok with LC_MESSAGES
// Specify location of translation tables
bindtextdomain("myAppPhp", "includes/locale");
bind_textdomain_codeset("myAppPhp", 'UTF-8');
// It's very important
// Choose domain
textdomain("myAppPhp");
// Translation is looking for in includes/locale/es_ES.utf8/LC_MESSAGESmyAppPhp.mo now
?>
<p><?=_("Welcome to My PHP Application");?></p>
<p><?=gettext("Have a nice day");?></p>
Ah, it's very important use locale should be install in the server
shell command "locale -a"
too see less /etc/locale.alias
The hosting server could be all locale installed
good luck
----
Server IP: 130.206.1.5
Probable Submitter: 87.222.191.34
----
Manual Page -- http://www.php.net/manual/en/function.gettext.php
Edit -- https://master.php.net/note/edit/93454
Del: integrated -- https://master.php.net/note/delete/93454/integrated
Del: useless -- https://master.php.net/note/delete/93454/useless
Del: bad code -- https://master.php.net/note/delete/93454/bad+code
Del: spam -- https://master.php.net/note/delete/93454/spam
Del: non-english -- https://master.php.net/note/delete/93454/non-english
Del: in docs -- https://master.php.net/note/delete/93454/in+docs
Del: other reasons-- https://master.php.net/note/delete/93454
Reject -- https://master.php.net/note/reject/93454
Search -- https://master.php.net/manage/user-notes.php