omcrn/ yii2-i18ncontent
此软件包的最新版本(v2.0.3)没有提供许可证信息。
显示所选语言的文本小部件、页面、文章
v2.0.3
2018-09-19 08:02 UTC
Requires
- php: >=5.4.0
- omcrn/yii2-base: ~0.2
- omcrn/yii2-imperavi-redactor: ^0.0.4
- trntv/yii2-aceeditor: ^2.0
- trntv/yii2-datetime-widget: ^1.0.0
- trntv/yii2-file-kit: ^1.0.0
- wbraganca/yii2-tagsinput: ^1.0
- yiisoft/yii2: ~2.0.0
- dev-master
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.18
- 1.1.17
- 1.1.16
- 1.1.15
- 1.1.14
- 1.1.13
- 1.1.12
- 1.1.11
- 1.1.10
- 1.1.9
- 1.1.8
- 1.1.7
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- v0.3.6
- v0.3.5
- v0.3.4
- v0.3.3
- v0.3.2
- v0.3.1
- v0.3.0
- v0.2.0
- v0.1.8
- v0.1.7
- v0.1.6
- v0.1.5
- v0.1.4
- v0.1.3
- v0.1.2
- v0.1.1
- v0.1.0
- dev-dbmenu
This package is not auto-updated.
Last update: 2024-09-28 23:41:22 UTC
README
yii2-i18ncontent是yii2模块,用于在不同语言中创建多种类型的内容。它支持创建以下内容
- 可翻译的文章类别和文章
- 可翻译的页面
- 带有可翻译标题文本的轮播图
- 可翻译的文本部分。
- 菜单内容(尚未可翻译)
安装
- 运行
composer require omcrn/yii2-i18ncontent
或在项目的composer.json
文件中添加"omcrn/yii2-i18ncontent": "~2.0.0"
。 - 确保您的数据库中有具有主键
id
的user
表。 - 从项目根目录运行迁移来创建表:
php console/yii migrate --migrationPath=@yii/i18n/migrations
- 从项目根目录运行迁移来创建表:
php console/yii migrate --migrationPath=@vendor/omcrn/yii2-i18ncontent/migrations
配置
在项目配置文件下的modules
部分添加以下代码
'i18ncontent' => [ 'class' => 'centigen\i18ncontent\Module', 'defaultLayout' => '/admin', //Default layout which will be used for rendering i18ncontent pages ],
在项目配置文件下的components
部分添加以下代码
"i18n" => [ "translations" => [ '...', 'i18ncontent' => [ 'class' => 'yii\i18n\PhpMessageSource', 'basePath' => '@vendor/omcrn/yii2-i18ncontent/messages', ], ] ] 'formatter' => [ 'class' => 'centigen\base\i18n\Formatter' ], 'i18ncontent' => [ 'class' => 'centigen\i18ncontent\I18nContent', 'userClass' => 'common\models\User', //User model class. If you do not have user model, generate it from user table. Make sure this models extends \yii\db\ActiveRecord class 'mediaUrlPrefix' => null, //In texts which may contain <img> or other media object tags (texts which come from WYSIWYG editors) // `$mediaUrlPrefix` strings are replaced with `$mediaUrlReplacement` string when calling `Html::encodeMediaItemUrls` // and vice versa when calling `Html::decodeMediaItemUrls` 'mediaUrlReplacement' => '{{media_item_url_prefix}}' //See `$mediaUrlPrefix` ],
将availableLocales
数组添加到应用程序配置的params
数组中。
在此处列出的每种语言旁边都会显示一个标签,以提供内容。
'params' => [ '...', 'availableLocales' => [ 'en-US' => 'English', 'ru-RU' => 'Русский' ... ], ]
管理网址
将以下网址追加到域名,以查看管理页面