承接 vintage/yii2-i18n 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

vintage/yii2-i18n

最新稳定版本:1.3.0

Composer 安装命令:

composer require vintage/yii2-i18n

包简介

Internalization module for automatic adding of translations to database

README 文档

README

Internalization module for Yii2


Internalization module for automatic adding of translations to database.

Based on Zelenin I18N module.

Total Downloads Latest Stable Version Latest Unstable Version

Installation

Install package

Run command

composer require vintage/yii2-i18n

or add

"vintage/yii2-i18n": "~1.1"

to the require section of your composer.json.

Configuration

  1. Configure I18N component in common part of your application
'components' => [
    'i18n' => [
        'class' => vintage\i18n\components\I18N::className(),
        'languages' => ['ru-RU', 'de-DE', 'it-IT'],
    ],
    // ...
],
  1. Configure module in backend part of your application
'modules' => [
	'i18n' => vintage\i18n\Module::className(),
	// ...
],
  1. Applying migrations
./yii migrate --migrationPath=@vintage/i18n/migrations

Usage

Go to http://backend.your-app.dev/translations for translating of messages.

PHP to database import

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

Run command

./yii i18n/import @common/messages

where @common/messages is path to app translations

Database to PHP export

Run command

./yii i18n/export @vintage/i18n/messages vintage/i18n

where @vintage/i18n/messages is path to app translations and vintage/i18n is translations category in DB.

Using yii category with database

Import translations from PHP files

./yii i18n/import @yii/messages

Configure I18N component

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

Caching

Cache will be updates automaticly if you updates translations in dashboard.

If you using \yii\caching\FileCache your config should be like following

// common/config/main.php
`components` => [
    // ...
    'i18n' => [
        'class'=> vintage\i18n\components\I18N::className(),
        'languages' => ['ru-RU', 'de-DE', 'it-IT'],
        'enableCaching' => true,
        'cache' => 'i18nCache',
    ],
    'i18nCache' => [
        'class' => \yii\caching\FileCache::className(),
        'cachePath' => '@frontend/runtime/cache',
    ],
],

Other

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

Read more about I18N in official guide.

Licence

License

This project is released under the terms of the BSD-3-Clause license.

Copyright (c) 2017, Vintage Web Production

统计信息

  • 总下载量: 4.99k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 40
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2017-06-07