Yii v2 snippet guide III

Comparing #11 with #12

Revision #12 was created by rackycz rackycz on Jan 21, 2021, 2:38:23 PM.

Translations

Content

[...]
\Yii::$app->language = $_SESSION['sys_lang'];
return true;
}
}
```
If you want to have the sys_lang in the URL, right being the domain name, follwing URL rules can be created in config/web.php, section components:
 
 
```php
 
'components' => [
 
 // ...
 
 'urlManager' => [
 
  'enablePrettyUrl' => true,
 
  'showScriptName' => false,
 
  'rules' => [
 
   // https://www.yiiframework.com/doc/api/2.0/yii-web-urlmanager#$rules-detail
 
   // https://stackoverflow.com/questions/2574181/yii-urlmanager-language-in-url
 
   // https://www.yiiframework.com/wiki/294/seo-conform-multilingual-urls-language-selector-widget-i18n
 
   '<sys_lang:[a-z]{2}>' => 'site',
 
   '<sys_lang:[a-z]{2}>/<controller:\w+>' => '<controller>',
 
   '<sys_lang:[a-z]{2}>/<controller:\w+>/<action:\w+>' => '<controller>/<action>',
 
  ],
 
 ],
 
],
 
```