ZF3 - Define language via url / route

0

I'm migrating to Zend Framework 3 and am having trouble with the following question:
In Skeleton, I made the internationalization settings as recommended by the documentation, with _Zend\I18n_ and _Zend\Mvc\I18n_ in _modules.config.php_ file. After that I added the following code in the file _autoload/global.php_ :

return [
'translator' => [
    'locale' => 'pt_BR',
    'translation_file_patterns' => [
        [
            'type'     => 'gettext',
            'base_dir' => getcwd() .  '/data/language',
            'pattern'  => '%s.mo',
        ],
    ],
];  

Along with creating the .mo file, the translations work very well if you change from "pt_BR" to "en_US" for example. But here comes the dilemma: How to change this via url / route?

Eg:

app.meusite.br (pt_BR/default)  
app.meusite.br/en (en_US)  
app.meusite.br/es (es_ES) 

And so on? The documentation has not helped and the few answers I found did not help me much.

You do not even have urls/rotas (/en, /es, etc) ... if there is a method in which the user can change the language (even without changing the url) and save it in a session would be great (because there will also be user registration and the language will also be saved).

    
asked by anonymous 16.04.2018 / 17:51

0 answers