vintage/yii2-i18n
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.
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
- Configure I18N component in common part of your application
'components' => [ 'i18n' => [ 'class' => vintage\i18n\components\I18N::className(), 'languages' => ['ru-RU', 'de-DE', 'it-IT'], ], // ... ],
- Configure module in backend part of your application
'modules' => [ 'i18n' => vintage\i18n\Module::className(), // ... ],
- 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
This project is released under the terms of the BSD-3-Clause license.
Copyright (c) 2017, Vintage Web Production
vintage/yii2-i18n 适用场景与选型建议
vintage/yii2-i18n 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.28k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2017 年 06 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「i18n」 「translation」 「translations」 「yii2」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 vintage/yii2-i18n 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 vintage/yii2-i18n 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 vintage/yii2-i18n 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Easy to use i18n translation PHP class for multi-language websites
A custom URL rule class for Yii 2 which allows to create translated URL rules
A Laravel Eloquent model trait for translatable resource
Deepl Automated translations for Laravel lang files
Bureaux A Partager Edit - Parse, validate, manipulate, and display dates in PHP w/ i18n support. Inspired by moment.js
Nette Framework adapter for I18n package
统计信息
- 总下载量: 5.28k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 25
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2017-06-07