D
D
Doniyor Mamatkulov2016-06-20 14:55:21
Yii
Doniyor Mamatkulov, 2016-06-20 14:55:21

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

2 answer(s)
K
Kirill Arutyunov, 2016-06-20
@arutyunov

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

S
Slava Vitrenko, 2016-06-20
@bagiroff777

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 question

Ask a Question

731 491 924 answers to any question