nstcactus / craft-translations-module
为Craft CMS站点添加可管理翻译的最简单方法
2.0.1
2024-04-21 15:37 UTC
Requires
- nstcactus/craft-utils: ^3.0 || ^4.0
README
入门
-
通过composer安装模块
composer require nstcactus/craft-translations-module
-
在Craft的
config/app.php
文件中加载模块<?php return [ 'modules' => [ 'translations-module' => [ 'class' => nstcactus\craftcms\modules\translations\TranslationsModule::class, // Optional properties 'translationCategory' => 'dico', 'translatableItemsTableName' => '{{%frontend_translatable_items}}', 'translationsTableName' => '{{%frontend_translations}}', ], ], ];
-
执行迁移以创建数据库表
./craft migrate/up --track translations-module
-
在Craft控制面板中添加一些翻译:
<craftUrl>/admin/translations
-
在模板中使用翻译
Voici une chaîne traduite : {{ 'app.translated.string'|t('dico') }}
路线图
- 更改数据库模式,使其尽可能接近
\yii\i18n\DbMessageSource
(理想情况下使用它代替\nstcactus\craftcms\modules\translations\i18n\DbMessageSource
) - 重构模块,将翻译与语言(
<lang>_<country>
)相关联,而不是与站点ID相关联 - 改进UI
- 使删除翻译更容易
- 添加一次性添加多个翻译的能力
- 添加导入/导出CSV格式的翻译的能力