yii2-localeurls
yii2-localeurls copied to clipboard
fix to handle different url rules in different languages for the same action
related to #129
I have tried to use different urls in different languages which are points to a static controller/action route.
With this modification and the following url rules it is working well. Order of the language related url rules is matter. Default language comes first then the rules for other languages.
...
'urlManager' => [
'class' => '\codemix\localeurls\UrlManager',
'languages' => ['en', 'hu'],
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'/' => 'frontend/default/landing',
[
'pattern' => '/jatek',
'route' => 'frontend/default/game',
'defaults' => ['language' => 'hu'],
],
[
'pattern' => '/feliratkozas',
'route' => 'frontend/default/subscribe',
'defaults' => ['language' => 'hu'],
],
[
'pattern' => '/game',
'route' => 'frontend/default/game',
'defaults' => ['language' => 'en'],
],
[
'pattern' => '/subscribe',
'route' => 'frontend/default/subscribe',
'defaults' => ['language' => 'en'],
],
],
],
...
I cannot manage to run tests locally, I will check this in travis.
I currently don't have time to take a closer look here. But I'm quite surprised that there are still problems with URL rules. If you check the current set of tests you'll see, that they are quite extensive and already try to check each and every aspect. It's crucial that you get those running locally first. Your change now seems to break things.
Ok, I also have no time to figure it out, why this change breaks the build.
I would have written tests, but there is no dependencies for the dev environment in the composer.json
.
But I will check soon how Travis runs the tests.
All you need should be phpunit. I'm using version 6 here via the global .phar file:
https://phpunit.de/getting-started/phpunit-6.html