nstcactus/craft-translations-module

为Craft CMS站点添加可管理翻译的最简单方法

2.0.1 2024-04-21 15:37 UTC

This package is auto-updated.

Last update: 2024-09-21 16:27:59 UTC


README

入门

  1. 通过composer安装模块

    composer require nstcactus/craft-translations-module
  2. 在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}}',
         ],
       ],
    ];
  3. 执行迁移以创建数据库表

    ./craft migrate/up --track translations-module
  4. 在Craft控制面板中添加一些翻译:<craftUrl>/admin/translations

  5. 在模板中使用翻译

    Voici une chaîne traduite : {{ 'app.translated.string'|t('dico') }}

路线图

  • 更改数据库模式,使其尽可能接近 \yii\i18n\DbMessageSource(理想情况下使用它代替 \nstcactus\craftcms\modules\translations\i18n\DbMessageSource
  • 重构模块,将翻译与语言(<lang>_<country>)相关联,而不是与站点ID相关联
  • 改进UI
    • 使删除翻译更容易
    • 添加一次性添加多个翻译的能力
  • 添加导入/导出CSV格式的翻译的能力