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.
<?php
$codeset = "UTF8"; putenv('LANG='.$lang.'.'.$codeset);
putenv('LANGUAGE='.$lang.'.'.$codeset);
bind_textdomain_codeset('mydomain', $codeset);
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'.