blaces
(Blaces)
1
Hi all,
Is it possible to localize (i18n) the name of controllers and actions in the URL?
Forexample:
http://yiiproject/site/login - in English
http://yiiproject/site/belepes - in Hungarian
These are call the site/login action.
http://yiiproject/site/about - in English
http://yiiproject/site/rolunk - in Hungarian
These are call the site/about action.
I need this feature for Seo.
phtamas
(Phtamas)
2
'rules' => [
[
'class' => 'yii\web\GroupUrlRule',
'prefix' => '',
'routePrefix' => '',
'ruleConfig' => [
'class' => 'yii\web\UrlRule',
'defaults' => ['language' => 'hu'],
],
'rules' => [
'/' => 'site/index',
'belepes' => 'site/login',
'rolunk' => 'site/about',
],
],
[
'class' => 'yii\web\GroupUrlRule',
'prefix' => 'en',
'routePrefix' => '',
'ruleConfig' => [
'class' => 'yii\web\UrlRule',
'defaults' => ['language' => 'en'],
],
'rules' => [
'/' => 'site/index',
'login' => 'site/login',
'about' => 'site/about',
],
],
\yii\helpers\Url::toRoute(['site/login', 'language' => \Yii::$app->language]);
It will generate URLs like ‘/belepes’ and ‘en/login’.