定制 itech-world/sulu-translator-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

itech-world/sulu-translator-bundle

Composer 安装命令:

composer require itech-world/sulu-translator-bundle

包简介

DeepL translation integration for Sulu CMS 3.x admin interface

README 文档

README

Itech World logo

Translator Bundle for Sulu

Developed by Steeven THOMAS

GitHub license Sulu compatibility

SuluTranslatorBundle integrates DeepL automatic translation into the Sulu CMS 3.x admin interface. Translate your page and article content with a single click, directly from the edit form.

📂 Requirements

🛠️ Features

  • Per-field translation button on text_line, text_area and text_editor fields
  • Bulk "Translate all" button in the form toolbar to translate every text field at once
  • Auto-detection of the source language by DeepL
  • Target language automatically set to the locale selected in the admin dropdown
  • Undo button to revert a translation to the previous value
  • HTML preservation for rich text fields (CKEditor content)
  • DeepL usage statistics page in admin settings (account type, billing period, character usage)
  • Permission-based access to the statistics page via Sulu role system
  • Pages and articles support

🇬🇧 Available translations

  • English
  • French
  • German

📦 Dependencies

📝 Installation

Composer

composer require itech-world/sulu-translator-bundle

Symfony Flex

If you don't use Symfony Flex, you can add the bundle to your config/bundles.php file:

return [
    // ...
    ItechWorld\SuluTranslatorBundle\ItechWorldSuluTranslatorBundle::class => ['all' => true],
];

Configuration

Step 1: Configure your DeepL API key

Add your DeepL API key to your .env or .env.local file:

DEEPL_API_KEY=your_deepl_api_key_here

Step 2: Create the bundle configuration

Create the file config/packages/itech_world_sulu_translator.yaml:

itech_world_sulu_translator:
    deepl_api_key: "%env(DEEPL_API_KEY)%"
    locale_mapping:
        en: "en-GB"
        fr: "fr"
        de: "de"

Note: The locale_mapping is optional. It maps Sulu locale codes to DeepL language codes. If a locale is not mapped, it will be converted to uppercase automatically (e.g. fr becomes FR). See DeepL supported languages for valid codes.

Step 3: Register the admin JavaScript

Edit the assets/admin/app.js to add the bundle in imports:

import 'sulu-itech-world-sulu-translator-bundle';

Step 4: BACK & Build admin assets

Edit the assets/admin/package.json to add the bundle to the list of bundles:

{
    "dependencies": {
        // ...
      "sulu-itech-world-sulu-translator-bundle": "file:../../vendor/itech-world/sulu-translator-bundle",
    }
}

In the assets/admin/ folder, run the following command:

npm install
npm run build

or

yarn install
yarn build

Step 5: Clear cache

php bin/adminconsole cache:clear

🔤 Per-field Translation

Once installed, a translate button (language icon) appears on every text_line, text_area and text_editor field in the page and article edit forms.

  1. Select the target language in the Sulu locale dropdown (top of the page)
  2. Click the translate button on any field
  3. The field content is sent to DeepL and replaced with the translation
  4. A green checkmark confirms the translation, and a red undo button appears next to it to revert to the original value

After translating individual fields, the green checkmark and red undo button are shown side by side:

Page with some fields translated — checkmark and undo buttons

🌍 Bulk Translation

A "Translate all" button is available in the form toolbar:

  1. Select the target language in the locale dropdown
  2. Click "Translate all" in the toolbar
  3. Confirm the action in the dialog
  4. All text fields are translated simultaneously

Bulk translate confirmation dialog

Page with all fields translated

Page before translation — translate buttons visible on each field

📊 DeepL Usage Statistics

The bundle provides a settings view accessible under Settings > DeepL Translator, showing your DeepL API usage:

  • Account type badge (Free or Pro)
  • Billing period dates (Pro accounts only)
  • Characters used vs. plan limit with a visual progress bar (green / yellow / red)
  • Refresh button and direct link to your DeepL dashboard

DeepL usage statistics page

Permissions

Access to the statistics page is controlled by the Sulu permission system. A "translator" entry appears under Settings in the role permissions. Enable the View permission to grant access.

Translator permission in role settings

📋 Supported Field Types

Sulu Field Type Support Notes
text_line Single-line text input
text_area Multi-line text area
text_editor Rich text

🔌 REST API Endpoints

The bundle exposes two admin API endpoints:

Method Endpoint Description
POST /admin/api/translator/translate Translate text content
GET /admin/api/translator/usage Get DeepL API usage stats

POST /admin/api/translator/translate

Request body:

{
    "text": "Bonjour le monde",
    "target": "en",
    "source": "fr",
    "html": false
}
Field Type Required Description
text string Yes Text content to translate
target string Yes Target Sulu locale code
source string No Source language (auto-detected if omitted)
html boolean No Set to true for rich text fields to preserve HTML markup

Response:

{
    "translation": "Hello world"
}

GET /admin/api/translator/usage

Response:

{
    "character_count": 42500,
    "character_limit": 500000,
    "account_type": "free",
    "start_time": null,
    "end_time": null
}

Note: start_time and end_time are only returned for Pro accounts. Free accounts will receive null for these fields.

🐛 Bug and Idea

See the open issues for a list of proposed features (and known issues).

💰 Support me

You can buy me a coffee to support me this plugin is 100% free.

Buy me a coffee

👨‍💻 Contact

x.com Linkedin

📘  License

This bundle is under the MIT License.

itech-world/sulu-translator-bundle 适用场景与选型建议

itech-world/sulu-translator-bundle 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 2, 最近一次更新时间为 2026 年 02 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「admin」 「translation」 「cms」 「sulu」 「deepl」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 itech-world/sulu-translator-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 itech-world/sulu-translator-bundle 我们能提供哪些服务?
定制开发 / 二次开发

基于 itech-world/sulu-translator-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 29
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 0
  • 开发语言: JavaScript

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-13