yiithings / yii2-i18n
Internationalization extension for Yii2 framework
Installs: 90
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- php: >=5.5.0
- gettext/gettext: ~4.2
- yiisoft/yii2: *
Requires (Dev)
- phpunit/phpunit: ^5.7
- yiisoft/yii2-gii: ^2.0
This package is auto-updated.
Last update: 2021-12-11 07:52:48 UTC
README
Internationalization extension for Yii2 framework.
This extension use Gettext as message source and provide Web GUI(gii) editing message source.
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist yiithings/yii2-i18n "*"
or add
"yiithings/yii2-i18n": "*"
to the require section of your composer.json
file.
Usage
Once the extension is installed, simply use it in your code by :
Add the component to your application.
'components' => [ 'i18n' => [ 'class' => 'yiithings\i18n\I18N' ] ]
Use functions:
echo __('Username'); __('Username'); // with echo echo _x('Username', 'yii'); _xe('Username', 'yii'); // with echo
Edit messages:
Use PoEdit create or edit your messages.
.po
and .mo
files default save path is @app/messages/
, e.g.
@app/messages/en-US.mo
. If you want to change path rule, please
see GettextMessageSource Class.