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.
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.
- 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], ];
- 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
- Add the file
config/packages/sulu_ai_translator.yamlwith 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.
- 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" }
- Import the frontend code by adding the following to your
assets/admin/app.js:
import "sulu-ai-translator-bundle";
- Install all npm dependencies and build the admin UI (see all options):
cd assets/admin
npm install
npm run build
- Add your Deepl API Key to the
.envfile:
DEEPL_API_KEY="..."
- Grant permissions in Sulu backend to access "DeepL Usage Statistics" view.
Limitations
- Currently only supports fields of type
input[type="text"],textareaand<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
- Add to
repositoriessection ofcomposer.json:
"repositories": [ { "type": "path", "url": "./../local-path-to-bundle" } ],
- Install bundle:
composer require robole/sulu-ai-translator-bundle:@dev
- Check the coding standards:
composer php-cs
- 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.querySelectorwith 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 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.88k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 18
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2024-07-31
