note 93454 deleted from function.gettext by googleguy
| From: | googleguy@php.net | Date: | Tue, 22 Oct 2013 11:16:47 +0000 |
| Subject: | note 93454 deleted from function.gettext by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-197066@lists.php.net to get a copy of this message | ||
Note Submitter: mario dot ugedo at gmail dot com
----
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