Yii v2 snippet guide III

Comparing #30 with #31

Revision #31 was created by rackycz rackycz on Feb 12, 2021, 9:16:44 AM.

test

Content

** My articles**
---
[...]
** Switching languages and Language in URL**
---
[...]
Now the language-switching links will produce URL like this: http://myweb.com/en/site/index . Without the rules the link would look like this: http://myweb.com/site/index?sys_lang=en . So the rule works in both directions. When URL is parsed and controllers are called, but also when a new URL is created using the URL helper.

**
 Search and replace Yii::t()** ---
 
Simple usage in format Yii::t('text','text') can be searched using following regex for example in Notepad++. If you want to modify it massively, you can use the "replace" command, also in Notepad++.

```
search: Yii::t\('([^']*)'[^']*'([^']*)'[^\)]*\)
replace with: Yii::t\('$1','$2'\)
```
[...]