Set link param $params['x-language-url']
:
yii\helpers\Url::current(['x-language-url'=>'es']); // "/es/"
yii\helpers\Url::toRoute(['site/login', 'x-language-url'=>'es']); // "/es/site/login"
yii\helpers\Html::a('Link', ['site/login', 'x-language-url'=>'es']); // "<a href='/es/site/login'>Link</a>"
It works for all links created by UrlManager.
Set parameter $params['x-language-url']=false
:
yii\helpers\Url::toRoute(['site/login', 'x-language-url'=>false]); // "/site/login"
If no language is specified by default in Yii::$app->params->languages
, then by
such links will be detected user's language with a redirect on translation.
User language is identified priority:
$_COOKIE['x-language-id']
- HTTP_ACCEPT_LANGUAGE
- Locale
Yii::$app->language