Giter VIP home page Giter VIP logo

yii2-i18n-module's Introduction

Yii2 I18N module

Yii2 i18n (internalization) module makes the translation of your application so simple

Installation

Composer

The preferred way to install this extension is through Composer.

Either run

php composer.phar require zelenin/yii2-i18n-module "dev-master"

or add

"zelenin/yii2-i18n-module": "dev-master"

to the require section of your composer.json

Usage

Configure I18N component in common config:

'i18n' => [
	'class' => Zelenin\yii\modules\I18n\components\I18N::className(),
	'languages' => ['ru-RU', 'de-DE', 'it-IT']
],

Configure I18N component in backend config:

'modules' => [
	'i18n' => Zelenin\yii\modules\I18n\Module::className()
],

Run:

php yii migrate --migrationPath=@Zelenin/yii/modules/I18n/migrations

Go to http://backend.yourdomain.com/translations for translating your messages

PHP to DB import

If you have an old project with PHP-based i18n you may migrate to DbSource via console.

Run:

php yii i18n/import @common/messages

where @common/messages is path for app translations

DB to PHP export

Run:

php yii i18n/export @Zelenin/yii/modules/I18n/messages zelenin/modules/i18n

where @Zelenin/yii/modules/I18n/messages is path for app translations and zelenin/modules/i18n is translations category in DB

Using yii category with DB

Import translations from PHP files

php yii i18n/import @yii/messages

Configure I18N component:

'i18n' => [
    'class'=> Zelenin\yii\modules\I18n\components\I18N::className(),
    'languages' => ['ru-RU', 'de-DE', 'it-IT'],
    'translations' => [
        'yii' => [
            'class' => yii\i18n\DbMessageSource::className()
        ]
    ]
],

Info

Component uses yii\i18n\MissingTranslationEvent for auto-add of missing translations to database

See Yii2 i18n guide

Author

Aleksandr Zelenin, e-mail: [email protected]

yii2-i18n-module's People

Contributors

zelenin avatar uran1980 avatar

Watchers

James Cloos avatar cooltheo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.