I am trying to run the Translation module on Zendframework 3, but it does not work for me.
In the module.config.php in the appplication module I have placed the following configuration:
'translator' => [
'locale' => 'de_DE',
'translation_file_patterns' => [
[
'type' => 'phparray',
'base_dir' => getcwd() . '/data/language',
'pattern' => 'lang.array.%s.php',
],
],
],
I have my language files in the /data/language folder named lang.array.de.php and lang.array.en.php with the content:
return array('All rights reserved' => 'Alle Rechte vorbehalten');
and respectively
return array('All rights reserved' => 'All rights reserved');
I am trying to set the German language in the IndexController of the application module:
$translator = new Translator();
$translator->addTranslationFilePattern('phparray', 'lang.array.de.php', 'lang.array.%s.php', 'en');
$translator->addTranslationFilePattern('phparray', 'lang.array.en.php', 'lang.array.%s.php', 'de');
$translator->setLocale('de');
And in the view script layout.phtmls I have called the translator:
<p>© 2016 by Examples Ltd. <?= $this->translate('All rights reserved') ?></p>
The main configuration file modules.config.php calls the modules:
return [
'Zend\Paginator',
'Zend\Navigation',
'Zend\Form',
'Zend\Db',
'Zend\Router',
'Zend\Validator',
'Zend\I18n',
'Zend\Mvc\I18n',
'Application',
'Album',
'Blog',
];
I get no errors when running the application, but the string is not translated too. Please can you revise and help for what is missing in my configuration/calls.