I have setted everything correctly and with all the possible variants but gettext never work, below my settings, and here the details:
- Tested on both Windows with XAMPP and Linux.
- Gettext is active on php.ini and with WordPress work good always.
- I confirm that the .mo and .po files are correct due work good with WordPress, created with Poedit.
I inserted the files
it_IT.mo, it_IT.po, it.mo, it.po, domain.mo, domain.po
(where domain is my domain) into the following folders:- C:\xampp\htdocs\sbphp\sb\lang
- C:\xampp\htdocs\sbphp\sb\lang\it
- C:\xampp\htdocs\sbphp\sb\lang\it_IT
- C:\xampp\htdocs\sbphp\sb\lang\locale\LC_MESSAGES\it
- C:\xampp\htdocs\sbphp\sb\lang\locale\LC_MESSAGES\it_IT
- C:\xampp\htdocs\sbphp\sb\lang\locale\it
- C:\xampp\htdocs\sbphp\sb\lang\locale\it_IT
- C:\xampp\htdocs\sbphp\sb\lang\LC_MESSAGES\it
- C:\xampp\htdocs\sbphp\sb\lang\LC_MESSAGES\it_IT
My code is this:
putenv('LANGUAGE=it'); //Variants: it_IT - it_IT.UTF-8- it.UTF-8
putenv('LC_ALL=it'); //Variants: it_IT - it_IT.UTF-8- it.UTF-8
putenv('LANG=it'); //Variants: it_IT - it_IT.UTF-8- it.UTF-8
define('PROJECT_DIR', realpath('./')); //Variants: without this constant
define('LOCALE_DIR', "../lang"); //Variants: without this constant
define('DEFAULT_LOCALE', 'it_IT'); //Variants: without this constant
$results = setlocale(LC_ALL, array('it_IT.UTF-8', 'it.UTF-8', 'it')); //Return 'it'
$results = bindtextdomain($domain, "../lang"); //It return the correct path C:\xampp\htdocs\sbphp\sb\lang - Variants: Locale - locale
$results = bind_textdomain_codeset($domain, 'UTF-8');
$results = textdomain($domain);
return gettext($string);
And never work.
My Problem:
setlocale();
returns "it", If I set wrong values returns false
.
bindtextdomain();
Returns the correct path C:\xampp\htdocs\sbphp\sb\lang, If I set wrong values it returns nothing.
bind_textdomain_codeset
Returns UTF-8.
bind_textdomain_codeset()
returns my correct domain. So I think there is not any error here. The output is the original (not translated) text.