gleads / yii18n
此软件包的最新版本(dev-master)没有可用的许可信息。
javascript文件的i18n
dev-master
2017-12-20 16:42 UTC
Requires
- php: >=5.6
- yiisoft/yii2: *
This package is not auto-updated.
Last update: 2024-09-21 17:29:23 UTC
README
要求
- PHP >= 5.6.x
- Yii >= 2.0.x
安装
在您的composer.json文件中添加"gleads/yii18n": "dev-master"
然后在您的终端中运行:composer update
使用方法
您必须在您的config/web.php中添加翻译模块
'modules' => [ 'translator' => [ 'class' => 'gleads\yii18n\TranslatorModule' ] ],
添加带有类'gleads\yii18n\PhpMessageSource'的消息源类
'components' => [
'i18n' => [
'translations' => [
'app*' => [
'class' => 'gleads\yii18n\PhpMessageSource', // Add This class
'fileMap' => [
'app' => 'app.php',
'app/error' => 'error.php',
],
],
],
],
],
注意:您需要在您的urlmanager中将enablePrettyUrl设置为true
在您的视图中,您必须添加翻译资源
gleads\yii18n\TranslatorAsset::register($this);
然后就可以使用了,您可以使用yii::t()样式使用它
在您的js文件中
yii.t('category', 'message', 'params');
待办事项
- 移除同步请求
- 添加复数形式
- 添加序数形式