note 59589 modified in function.gettext by danbrown
| From: | danbrown@php.net | Date: | Tue, 08 Sep 2009 22:30:40 +0000 |
| Subject: | note 59589 modified in function.gettext by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-160336@lists.php.net to get a copy of this message | ||
Default behavior is name .mo file equally in every language version:
===
locale_dir
--- en_US
------ LC_MESSAGES
--------- lang.mo
--- sk_SK
------ LC_MESSAGES
--------- lang.mo
===
I think, better form is:
===
locale_dir
--- en_US
------ LC_MESSAGES
--------- en.mo
--- sk_SK
------ LC_MESSAGES
--------- sk.mo
===
Then the following code works very well (surprisingly on win32 too), and you don't need restart
apache and do other confusing things:
<?php
$gettext_domain = 'sk'; // change by language
setlocale(LC_ALL, 'sk_SK.UTF-8'); // change by language, directory name sk_SK, not
sk_SK.UTF-8
bindtextdomain($gettext_domain, "lang");
textdomain($gettext_domain);
bind_textdomain_codeset($gettext_domain, 'UTF-8');
?>
Have nice day :-)
--was--
Default behavior is name .mo file equally in every language version:
===
locale_dir
--- en_US
------ LC_MESSAGES
--------- lang.mo
--- sk_SK
------ LC_MESSAGES
--------- lang.mo
===
I think, better form is:
===
locale_dir
--- en_US
------ LC_MESSAGES
--------- en.mo
--- sk_SK
------ LC_MESSAGES
--------- sk.mo
===
Then the following code works very well (surprisingly on win32 too), and you don't need restart
apache and do other confusing things:
$gettext_domain = 'sk'; // change by language
setlocale(LC_ALL, 'sk_SK.UTF-8'); // change by language, directory name sk_SK, not
sk_SK.UTF-8
bindtextdomain($gettext_domain, "lang");
textdomain($gettext_domain);
bind_textdomain_codeset($gettext_domain, 'UTF-8');
Have nice day :-)
http://php.net/manual/en/function.gettext.php