Revision #110 was created by rackycz on Sep 23, 2019, 12:25:46 PM.
typos
Content
[...]
And your index.php should be here:
- C:\xampp\htdocs\basic\web\index.php
If you set things correctly up, following URL will open your demo application. Now it will probably throw an exception:
- [http://localhost/basic/web/](http://localhost/basic/web/)
**The Exception is removed by enterinng any text into attribute 'cookieValidationKey' in file**:
- C:\xampp\htdocs\basic\config\web.php
[...]
- If a validator needs the method, it cannot be converted into JavaScript so the rule is checked only in the moment when user sends the form to the server - after successful JavaScript validation.
Now you can also create **CRUD** fotr the USser model using GII:
*(Note that cs-CZ is for Czech Lanuage. For German you should use de-DE etc. Use any other language if you want.)*
The idea behind is that in the code there are used only English texts and if you want to change from English to some other language this file will be used.
Now go to file config/web.php, find section "components" and paste this codee i18n section:
```php
[...]
Explanation of the asterisk * can be found in article [https://www.yiiframework.com/doc/guide/2.0/en/tutorial-i18n](https://www.yiiframework.com/doc/guide/2.0/en/tutorial-i18n)
You surely saw that in views and models there are translated-texts saved like this:
```php
[...]
```
**Switching languages + session + lang-dropdown in the top menu**
---
First lets add to file config/params.php attributes with list of supported languages:
[...]
```
Now in the top-right corner you can see a new drop-down-list with list of 2 languages. If one is selected, action "site/setLang" is uscalled so we have to create it in SiteController.
*Note that this approach will always redirect user to the new action and his work will be lost. Nevertheless this approach is very simple so I am using it in small projects. More complex projects may require an ajax call when language is changed and then updating texts using javascript so reload is not needed and user's work is preserved. But I expect that when someone opens the web, he/she sets the language immediately and then there is no need for further changes.*