Revision #59 has been created by rackycz on Sep 20, 2019, 1:40:26 PM with the memo:
i18n
« previous (#58) next (#60) »
Changes
Title
unchanged
Yii v2 for beginners
Category
unchanged
Tutorials
Yii version
unchanged
2.0
Tags
unchanged
tutorial,beginner,yii2
Content
changed
[...]
- Search Model Class = app\models\UserSearch
- Controller Class = app\controllers\UserController
- View Path can be empty or you can set: views\user
- Again enable i18n
And then you can edit users on this URL: [http://localhost/basic/web/index.php?r=user](http://localhost/basic/web/index.php?r=user) ... but it is not all. You shouldhave to modify the view-files so that correct input
fields are displayed!
Open folder views\user and do following:[...]
i18n translations + Session
---
... text ...Translations are fairly simple, but I probably didnt read manuals carefully so it took me some time.
First create following folders and file. (Note that cs-CZ is for Czech Lanuage. For German you should use de-DE etc.) The idea behind is that in the code ther are used only English texts and if you want to change from English to some other language the files bellow are used.
- "C:\xampp\htdocs\basic\messages\cs-CZ\app.php"
- "C:\xampp\htdocs\basic\messages\de-DE\app.php"
Now ho to file config/web.php, find section "components" and paste this code:
```php
'components' => [
'i18n' => [
'translations' => [
'*' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '@app/messages',
'sourceLanguage' => 'en-US',
'fileMap' => [
'app' => 'app.php',
],
],
],
], // end of 'i18n'
// ... other configurations
], // end of 'components'
```
Access rights
---
... text ...