Difference between #122 and #123 of
Yii v2 snippet guide

Revision #123 has been created by rackycz on Oct 4, 2019, 8:30:21 AM with the memo:

translations
« previous (#122) next (#124) »

Changes

Title unchanged

Yii v2 snippet guide

Category unchanged

Tutorials

Yii version unchanged

2.0

Tags unchanged

tutorial,beginner,yii2

Content changed

[...]
**i18n translations**
---
Translations are fairly simple, but I probably didnt read manuals carefully so it took me some time.

**1 - Translating short texts and captions**
 
 
First create following folders and file.

- "C:\xampp\htdocs\basic\messages\cs-CZ\app.php"
[...]
```

**2 - Translating long texts and whole views**
 
-
 
 
If you have a view with long texts and you want to translate it into a 2nd language, it is not good idea to use the previous approach, because it uses the English text as the ID. 
 
 
It is better to translate the whole view. How? ... Just create a sub-folder next to the view and give it name which will be identical to the target-lang-ID. In my case the 2nd language is Czech so I created following folder and copied my view in it. So now I have 2 identical views with identical names:
 
 
- "C:\xampp\htdocs\chatar\views\site\about.php" ... English
 
- "C:\xampp\htdocs\chatar\views\site\cs-CZ\about.php" ... Czech
 
 
Yii will automatically use the Czech version if needed.
 
 
**Switching languages + session + lang-dropdown in the top menu**
---
First lets add to file config/params.php attributes with list of supported languages:

```php
<?php
[...]
7 0
4 followers
Viewed: 254 368 times
Version: 2.0
Category: Tutorials
Written by: rackycz
Last updated by: rackycz
Created on: Sep 19, 2019
Last updated: 5 months ago
Update Article

Revisions

View all history