Search code examples
internationalizationyii2url-routingyii-url-manager

How to set urlmanager rule on multilanguage website in yii2?


We have multilanguage(ua, ru, en) website. And site language automatically inserts in url before any calling to controller/action.

For example if language is 'ua' than request to site/index will be

ourwebsite.com/ua/controller/action 

not

ourwebsite.com/controller/action

i18n module is standart yii2 i18n module.

I want to set in urlManager, that if language is 'ua' then you can download file. But if language is 'ru' or 'en' and you go on

ourwebsite.com/ru/download
or
ourwebsite.com/en/download

then you can't download file.

I tried:

'<language:(ua)>/download' => 'site/download'

But it doesn't work.

if to set

'ua/download' => 'site/download'

it will work on

ourwebsite.com/ua/ua/download
ourwebsite.com/ru/ua/download
ourwebsite.com/en/ua/download

Solution

  • There is an extension for that-> Extension