语言路径是:
locale \ es_ES \ LC_MESSAGES \ myapp.po和.mo
我使用了这个课程https://github.com/oscarotero/Gettext。
include_once "gettext/autoloader.php";
$locale = 'es_ES';
use Gettext\GettextTranslator;
//Create a new instance
$t = new GettextTranslator();
//It detects the environment variables to set the locale, but you can change it:
$t->setLanguage('es_ES');
//Load the domains:
$t->loadDomain('myapp', 'Locale');
//this means you have the file "project/Locale/gl/LC_MESSAGES/messages.po"
//Now you can use it in your templates
echo $t->gettext('My Name');