I am trying to use \Phalcon\Translate\Adapter\Gettext
to create a multilanguage site.
I have searched in the forum and i 've found a previous discussions about the same problem (https://forum.phalcon.io/discussion/1150/need-help-with-gettext-solved#C28767), but even following that I did not manage to succeed.
I created the folders following the instructions (path/to/modules/moduleName/Language/it_IT/LC_MESSAGES/
and messages.po and .mo inside)
In my BaseController I have the method _getTranslation()
with the following content:
$translator = new \Phalcon\Translate\Adapter\Gettext(array(
'locale' => 'it_IT.utf8',
'file' => 'messages',
'directory' => __DIR__ . '../Language/'
));
return $translator;
Then the IndexController extends that with:
$this->view->setVar("translator", $this->_getTranslation());
And finally i call it in volt:
{{translator._("Hello world")}}
So far I've followed the instructions that seemed to solve the problem in the other dicusssion. Than I saw that I don't have the file `/etc/locale.gen` (that is required I think), but even with the command `locale-gen` it is not created.
Anybody knows a possible reason for that? Is there another way to create it maybe?