note 89076 added to function.setlocale
| From: | brice/axice/be at osu1 dot php dot net | Date: | Fri, 20 Feb 2009 13:19:22 +0000 |
| Subject: | note 89076 added to function.setlocale | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-150889@lists.php.net to get a copy of this message | ||
Pay attention to the syntax.
- UTF8 without dash ('-')
- locale.codeset and not locale-codeset.
Stupid newbie error but worth knowing them when starting with gettext.
$codeset = "UTF8"; // warning ! not UTF-8 with dash '-'
// for windows compatibility (e.g. xampp) : theses 3 lines are useless for linux systems
putenv('LANG='.$lang.'.'.$codeset);
putenv('LANGUAGE='.$lang.'.'.$codeset);
bind_textdomain_codeset('mydomain', $codeset);
// set locale
bindtextdomain('mydomain', ABSPATH.'/locale/');
setlocale(LC_ALL, $lang.'.'.$codeset);
textdomain('mydomain');
where directory structure of locale is (for example) :
locale/fr_FR/LC_MESSAGES/mydomain.mo
locale/en_US/LC_MESSAGES/mydomain.mo
and ABSPATH is the absolute path to the locale dir
further note, under linux systems, it seems to be necessary to create the locale at os level using
'locale-gen'.
----
Server IP: 213.246.51.26
Probable Submitter: 81.242.242.247
----
Manual Page -- http://www.php.net/manual/en/function.setlocale.php
Edit -- https://master.php.net/note/edit/89076
Del: integrated -- https://master.php.net/note/delete/89076/integrated
Del: useless -- https://master.php.net/note/delete/89076/useless
Del: bad code -- https://master.php.net/note/delete/89076/bad+code
Del: spam -- https://master.php.net/note/delete/89076/spam
Del: non-english -- https://master.php.net/note/delete/89076/non-english
Del: in docs -- https://master.php.net/note/delete/89076/in+docs
Del: other reasons-- https://master.php.net/note/delete/89076
Reject -- https://master.php.net/note/reject/89076
Search -- https://master.php.net/manage/user-notes.php