Yii v2 snippet guide III

Comparing #18 with #19

Revision #19 was created by rackycz rackycz on Jan 21, 2021, 8:45:00 PM.

Yiit regex

Content

[...]
'<sys_lang:[a-z]{2}>/<controller:\w+>/<action:\w+>' => '<controller>/<action>',
],
],
],
```
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'\)
 
```