Hi there, so I have some config setup on to use translations using phpArray in my config/global.php as such:
'translator' => [
'translation_file_patterns' => [
[
'type' => 'phpArray',
'base_dir' => ROOT_PATH . '/data/language/',
'pattern' => '%s.php',
],
],
],
In my home/first page all translation are loaded successfully between EN and PT. But as I try to use translated routes like so:
'router' => [
'routes' => [
'home' => [
'type' => Segment::class,
'options' => [
'route' => '/[:lang/]',
'constraints' => [
'lang' => '[a-z]{2}',
],
'defaults' => [
'controller' => Controller\IndexController::class,
'action' => 'index',
],
],
'may_terminate' => true,
'child_routes' => [
'plugin' => [
'type' => Segment::class,
'options' => [
'route' => '{plugin}/',
'defaults' => [
'controller' => Controller\IndexController::class,
'action' => 'plugin',
],
],
'may_terminate' => true,
],
'contacts' => [
'type' => Segment::class,
'options' => [
'route' => '{contacts}/',
'defaults' => [
'controller' => Controller\IndexController::class,
'action' => 'contacts',
],
],
'may_terminate' => true,
],
],
],
],
],
As I navigate to those child routes of /plugin/ or /contacts/ they lose the translated strings and return the default index value of $this->translate(string);
I have setup the in global as well the TranslatorAwareTreeRouteStack class like so:
'router' => [
'router_class' => Laminas\Mvc\I18n\Router\TranslatorAwareTreeRouteStack::class,
],
Here are my language files.
EN:
<?php
return [
// Top Bar
'Client Support' => 'Client Support',
// Menu
'Plugin' => 'Plugin',
'Contacts' => 'Contacts',
'Register' => 'Register',
'Login' => 'Login',
// Routes
'plugin' => 'plugin',
'contacts' => 'contacts',
];
PT:
<?php
return [
// Top Bar
'Client Support' => 'Apoio ao Cliente',
// Menu
'Plugin' => 'Plugin',
'Contacts' => 'Contactos',
'Register' => 'Registar',
'Login' => 'Entrar',
// Routes
'plugin' => 'plugin',
'contacts' => 'contactos',
];