raffaelj/cockpit-babel

管理Cockpit CMS v1和v2模块的翻译

安装: 26

依赖项: 2

建议者: 0

安全性: 0

星星: 2

关注者: 1

分支: 0

开放问题: 2

语言:Hack

类型:cockpit-module

0.3.2 2023-02-05 10:44 UTC

This package is auto-updated.

Last update: 2024-09-10 15:34:03 UTC


README

使用图形用户界面管理Cockpit CMS v1Cockpit CMS v2模块和Multiplane主题的翻译。

用法

  • 以管理员身份登录(或具有babel管理权限)
  • 转到“设置”-->“Babel”
  • 如果您使用Cockpit CMS v1
    • 点击“其他”标签页
    • 点击“重构i18n文件”按钮。现在Babel插件已初始化,文件/文件夹结构已适应新位置。
  • 翻译字符串并点击“保存”按钮

配置

<?php
return [
    'app.name' => 'My app',

    // set entry level languages in cockpit cms v1
    // use the gui instead to change locales in cockpit cms v2
    'i18n' => 'de',
    'languages' => [
        'default' => 'Deutsch',
        'fr' => 'Francais',
    ],

    // set admin ui languages
    'babel' => [
        'languages' => [
            'de' => 'Deutsch',
            'fr' => 'Francais',
        ],
    ],
];

要求

  • PHP >= 7.4

概念

Cockpit CMS v1

文件/文件夹结构

  • config/cockpit/i18n/{locale}.php
    • 必须存在以供用户选择语言
  • 所见即所得字段(tinymce):#pstorage:assets/cockpit/i18n/tinymce/{locale}.js
.
├── config
|   ├── cockpit
|   |   └── i18n
|   |       ├── de.php (must exist)
|   |       └── fr.php (must exist)
|   └── config.php
├── storage
|   └── assets
|       └── cockpit
|           └── i18n
|               └── tinymce
|                   ├── de.js
|                   └── fr.js

Cockpit CMS v2

文件/文件夹结构

  • config/i18n/App/{locale}.php
    • 必须存在以供用户选择语言
    • 必须存在以加载其他模块i18n文件
  • 所见即所得字段(tinymce):应通过App.on('field-wysiwyg-init', function(opts) {opts.language_url = 'path/to/tinymce/locale.js';});(未测试)进行翻译
.
├── config
|   ├── i18n
|   |   ├── App
|   |   |   ├── de.php (must exist)
|   |   |   └── fr.php (must exist)
|   |   └── {module}
|   |       ├── de.php
|   |       └── fr.php
|   └── config.php
├── path/to/tinymce/{locale}.js (not tested)

Babel插件

我喜欢Cockpit v2的新文件夹结构,并将其适应在这个插件中。

文件/文件夹结构

.
├── config
|   ├── i18n
|   |   ├── {module}
|   |   |   ├── de.php
|   |   |   └── fr.php
|   |   ├── de.php (must exist - @meta and unassigned strings)
|   |   └── fr.php (must exist - @meta and unassigned strings)
|   └── config.php
├── storage/assets/cockpit/i18n/tinymce/{locale.js} (not automated, yet)

安装

将此存储库复制到/addons目录并命名为Babel或使用cli。

通过git

cd path/to/cockpit
git clone https://github.com/raffaelj/cockpit_Babel.git addons/Babel

通过cp cli(Cockpit CMS v1)

cd path/to/cockpit
./cp install/addon --name Babel --url https://github.com/raffaelj/cockpit_Babel/archive/main.zip

通过composer(Cockpit CMS v1)

确保在项目的composer.json文件中定义了cockpit插件的路径。

{
    "name": "my/cockpit-project",
    "extra": {
        "installer-paths": {
            "addons/{$name}": ["type:cockpit-module"]
        }
    }
}
cd path/to/cockpit-root
composer create-project --ignore-platform-reqs aheinze/cockpit .
composer config extra.installer-paths.addons/{\$name} "type:cockpit-module"

composer require --ignore-platform-reqs raffaelj/cockpit-babel

版权和许可

版权所有2022 Raffael Jesche,MIT许可。

有关更多信息,请参阅LICENSE