Answer the question
In order to leave comments, you need to log in
How to make multilingual in Yii2?
Good afternoon!
I am doing multilingualism on the site according to the article Duc . Everything works, except for one small bug. Links are formed like this: test.local/ru/ru/user/index , that is, the letters of the language are displayed twice, and accordingly the page Not found.)) If so test.local/ru/user/index, then everything is OK. What needs to be changed so that the language is correctly written in the URL?
Answer the question
In order to leave comments, you need to log in
The toaster often refers to this article and people constantly have questions.
Although there is a great extension with similar functionality that works great: https://github.com/codemix/yii2-localeurls
You just need to repeat exactly what is in the article. There are only two errors - the widget class name should be Wlang, not Lang, the second one is in the url rule.
And so, more information is needed. Is the urlRule correct in the config?
It should be like this:
(please note, I removed the "asterisk" from the rule,)
'/' => 'site/index',
'<controller:\w+>/<action:\w+>/'=>'<controller>/<action>'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question