Gettext在我的localhost上不起作用

I tried to start with gettext() but it doesn't work on my localhost.

My simple code:

<?php
$language='en';
putenv("LANG=$language"); 
setlocale(LC_ALL,$language);

$domain='test';
bindtextdomain($domain,"languages"); 
textdomain($domain);

echo _("Simple string to translate");

I have folder languages and in this folder another folder en but files are not creating. Thanks for help

this is a good solution to set up your languages and call the translations from .po files. PHP is reading only .po so make sure to have that file's extension. In addition test your locale system if it is supporting the xy_XY format or the xy format: under linux use this line: locale -a and you will check how the locale is writed and supported. Under windows: check the system.io file.

//get the location and set the languages
define('SESSION_LOCALE_KEY', 'ix_locale');
define('DEFAULT_LOCALE', 'en_US');
define('LOCALE_REQUEST_PARAM', 'lang');
define('WEBSITE_DOMAIN', 'messages');

if (array_key_exists(LOCALE_REQUEST_PARAM, $_REQUEST)) {
    $current_locale = $_REQUEST[LOCALE_REQUEST_PARAM];
    $_SESSION[SESSION_LOCALE_KEY] = $current_locale;
} elseif (array_key_exists(SESSION_LOCALE_KEY, $_SESSION)) {
    $current_locale = $_SESSION[SESSION_LOCALE_KEY];
} else {
    $current_locale = DEFAULT_LOCALE;
}

putenv("LC_ALL=$current_locale");
setlocale(LC_ALL, $current_locale);
bindtextdomain(WEBSITE_DOMAIN, dirname(__FILE__) . '/lang');
bind_textdomain_codeset(WEBSITE_DOMAIN, 'UTF-8');
textdomain(WEBSITE_DOMAIN);