定制 robole/sulu-ai-translator-bundle 二次开发

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

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

robole/sulu-ai-translator-bundle

Composer 安装命令:

composer require robole/sulu-ai-translator-bundle

包简介

Translate any type of content using DeepL

README 文档

README

SuluAITranslatorBundle

Sulu bundle that integrates DeepL API for bulk and single translations of content fields.

GitHub release Supports Sulu 3.0 or later

Demonstration of content field translation

Features

  • DeepLService to fetch translations and usage statistics from DeepL API
  • "Usage statistics" admin view with permission
  • Translation button next to input fields
  • Toolbar button to bulk translate all fields on page, snippet and article edit views
  • Supports Sulu 3

Installation

This bundle requires PHP 8.2 or later. Make sure to have installed Node 18 or later for building the Sulu administration UI.

  1. Open a command console, enter your project directory and run:
composer require robole/sulu-ai-translator-bundle

⚠️ Sulu 2.6 users please install the v1.1 branch:

composer require robole/sulu-ai-translator-bundle:^1.1

If you're not using Symfony Flex, you'll also need to add the bundle in your config/bundles.php file:

return [
    //...
    Robole\SuluAITranslatorBundle\SuluAITranslatorBundle::class => ['all' => true],
];
  1. Register the new routes by adding the following to your config/routes/sulu_admin.yaml:
sulu_ai_translator:
    resource: "@SuluAITranslatorBundle/Resources/config/routes_admin.yaml"
    prefix: /admin/api
  1. Add the file config/packages/sulu_ai_translator.yaml with the following configuration:
sulu_ai_translator:
    deepl_api_key: "%env(DEEPL_API_KEY)%"
    locale_mapping:
        en: "en-GB"

Via locale_mapping you can map a locale key from your webspace to the according official DeepL target language. Use value null for languages that should not be translatable.

  1. Reference the frontend code by adding the following to your assets/admin/package.json:
"dependencies": {
    "sulu-ai-translator-bundle": "file:../../vendor/robole/sulu-ai-translator-bundle/src/Resources/js"
}
  1. Import the frontend code by adding the following to your assets/admin/app.js:
import "sulu-ai-translator-bundle";
  1. Install all npm dependencies and build the admin UI (see all options):
cd assets/admin
npm install
npm run build
  1. Add your Deepl API Key to the .env file:
DEEPL_API_KEY="..."
  1. Grant permissions in Sulu backend to access "DeepL Usage Statistics" view.

Limitations

  • Currently only supports fields of type input[type="text"], textarea and <CkEditor />
  • Translations are applied on the frontend, giving content creators the ability to check translation quality and undo changes
  • Links to internal pages within text fields have to be updated by hand (obviously)

Local development

  1. Add to repositories section of composer.json:
    "repositories": [
        {
            "type": "path",
            "url": "./../local-path-to-bundle"
        }
    ],
  1. Install bundle:

composer require robole/sulu-ai-translator-bundle:@dev

  1. Check the coding standards:

composer php-cs

  1. Apply coding standards:

composer php-cs-fix

Troubleshooting

If a translation request returns the input text, it is very likely that the language key(s) defined in your locale_mapping bundle configuration are not supported by DeepL. This will be indicated in the response object.

Ideas for next versions

  • Add Symfony Recipe for quicker installation of bundle.
  • Replace document.querySelector with store-based approach for toggling blocks.
  • Enable configuration of translation strictness for each language (e.g. formal, informal, etc.)
  • Add a dropdown popup next to translation button for overwriting source and target language of a field

Disclaimer

This bundle uses the DeepL API to provide translation services. This project is not affiliated, associated, authorized, endorsed by, or in any way officially connected with DeepL SE or any of its subsidiaries or affiliates. The use of the DeepL API in this bundle is purely for functionality purposes and does not imply any relationship with the DeepL company.

DeepL is a registered trademark of DeepL SE.

robole/sulu-ai-translator-bundle 适用场景与选型建议

robole/sulu-ai-translator-bundle 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 1.88k 次下载、GitHub Stars 达 18, 最近一次更新时间为 2024 年 07 月 31 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 1.88k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 18
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 1

GitHub 信息

  • Stars: 18
  • Watchers: 3
  • Forks: 7
  • 开发语言: JavaScript

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-07-31