|
|
|
@ -41,7 +41,11 @@ Basic message translation
|
|
|
|
|
|
|
|
|
|
### Strings translation |
|
|
|
|
|
|
|
|
|
Yii basic message translation that works without additional PHP extension and |
|
|
|
|
Yii basic message translation that works without additional PHP extension. |
|
|
|
|
|
|
|
|
|
```php |
|
|
|
|
echo \Yii::t('app', 'This is a string to translate!'); |
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### Named placeholders |
|
|
|
@ -60,9 +64,8 @@ $sum = 42;
|
|
|
|
|
echo \Yii::t('app', 'Balance: {0}', $sum); |
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
> **Tip**: When messages are extracted and passed to translator, he sees strings only. For the code above extracted message will be |
|
|
|
|
> "Balance: {0}". It's not recommended to use positional placeholders except when there's only one and message context is |
|
|
|
|
> clear as above. |
|
|
|
|
> **Tip**: Try keep message strings meaningful and avoid using too many positional parameters. Remember that |
|
|
|
|
> translator has source string only so it should be obvious about what will replace each placeholder. |
|
|
|
|
|
|
|
|
|
Advanced placeholder formatting |
|
|
|
|
------------------------------- |
|
|
|
|