Closed Stephirio closed 4 years ago
To use Translator
, you have to export the .po file to PhpArray format.
$translations = Translations::fromPoFile('locales/en.po');
$translations->toPhpArrayFile('locales/en.php');
//load the php array in the translator:
$t->loadTranslations('locales/en.php');
Here's more info: https://github.com/php-gettext/Gettext#translator
To use
Translator
, you have to export the .po file to PhpArray format.$translations = Translations::fromPoFile('locales/en.po'); $translations->toPhpArrayFile('locales/en.php'); //load the php array in the translator: $t->loadTranslations('locales/en.php');
Here's more info: https://github.com/php-gettext/Gettext#translator
Thank you very much! Sorry my ignorance but I'm trying to learn. Anyway you answered very fast!
I tried to do this in my code
use Gettext\Translator; $t = new Translator(); $t->loadTranslations('locales/en.po'); echo $t->gettext('hi'); $t->register(); echo __('hi');
but i get nothing