yac / yii18n
此包已被废弃,不再维护。未建议替代包。
最新版本(dev-master)的此包没有提供许可信息。
JavaScript 文件的 i18n
dev-master
2017-03-08 13:15 UTC
Requires
- php: >=5.6
- yiisoft/yii2: *
This package is not auto-updated.
Last update: 2018-10-28 08:52:23 UTC
README
要求
- PHP >= 5.6.x
- Yii >= 2.0.x
安装
在您的 composer.json 文件中添加 "yac/yii18n": "dev-master"
然后在您的终端中运行: composer update
用法
您必须在 config/web.php 中添加翻译模块
'modules' => [ 'translator' => [ 'class' => 'yac\yii18n\TranslatorModule' ] ],
添加类消息源,类名为 'yac\yii18n\PhpMessageSource'
'components' => [
'i18n' => [
'translations' => [
'app*' => [
'class' => 'yac\yii18n\PhpMessageSource', // Add This class
'fileMap' => [
'app' => 'app.php',
'app/error' => 'error.php',
],
],
],
],
],
注意:您需要将 urlmanager > enablePrettyUrl 设置为 true
在您的视图中添加翻译资源
yac\yii18n\TranslatorAsset::register($this);
然后它就可以使用了,您可以像使用 yii::t() 一样使用它
在您的 JS 文件中
yii.t('category', 'message', 'params');
待办事项
- 移除同步请求
- 添加复数
- 添加序数