Skip to content

Latest commit

 

History

History
61 lines (44 loc) · 1.71 KB

README.md

File metadata and controls

61 lines (44 loc) · 1.71 KB

Yii2 I18N

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

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.