elair
(Reusch Lukas)
January 14, 2014, 12:48pm
1
I want to translate my routes.
example.de/contakt
example.com/kontakt
I used the I18N Subdomains and URL rules tutorial from the wiki.
Now I can switch the language and the urls are correctly translated.
In the views I want to create a link to /contact. But how to do this dynamically? Is it possible to get the correct path backward from the urlManager?
redguy
(Maciej Lizewski)
January 14, 2014, 2:25pm
2
in fact it is working like that already.
elair
(Reusch Lukas)
January 14, 2014, 2:38pm
3
If I add a route in the main.php:
'kontakt' => 'site/contact'
And try to generate an url:
<?php echo $this->createUrl('site/contact')); ?>
It returns example.com/site/contact
redguy
(Maciej Lizewski)
January 14, 2014, 10:39pm
4
elair:
If I add a route in the main.php:
'kontakt' => 'site/contact'
And try to generate an url:
<?php echo $this->createUrl('site/contact')); ?>
It returns example.com/site/contact
it depends where you add this rule. First matching rule wins, so try to add it as first rule and check again. Also try absolute notation: $this->createUrl(’/site/contact’));
elair
(Reusch Lukas)
January 15, 2014, 4:48pm
5
Thank you!
Problem was, the default routes matched the URLs before the custom translated routes.