A
A
alysenko2017-05-02 13:33:23
Yii
alysenko, 2017-05-02 13:33:23

How can Yii2 organize multilingualism using codemix/yii2-localeurls?

I use codemix/yii2-localeurls in a project on Yii2 to organize multilingualism. There are two languages ​​ua, ru. The default is ua.
The URLs are organized in such a way that the language is not displayed by default:
site.com - Ukrainian version,
site.com/ru - Russian version.
The problem is this:
in order to switch to a certain language, you need to explicitly specify it in the url.
That is, if I am on site.com/ru and go to site.com, then I will still be redirected to site.com/ru until I explicitly specify site.com/ua, only then will I go to site.com.
How can you make it so that when navigating through site.com, the user gets to site.com, and not redirected to the language version, the language of which is recorded in the cookie?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alysenko, 2017-05-02
@alysenko

Resolved the issue. It turned out to be much easier than I thought.
I'll leave it here, maybe it will be useful for someone.
If you do not explicitly specify the language in the url, then by default codemix/yii2-localeurls uses a more appropriate language using the browser settings, to disable this you need to specify the following parameters:
// disable user language detection
'enableLanguageDetection' => false,
// disable user redirection to a more suitable language
'enableLanguagePersistence' => false,

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question