Sulu bundle that integrates DeepL API for bulk and single translations of content fields (pages, snippets, forms). This bundle is in alpha-stage and should be treated as such.
AITranslatorBundle features:
- DeeplService to fetch translations and usage statistics from DeepL API
- Usage statistics admin view
- Translation button next to input fields
- Toolbar button to bulk translate all fields
- Permissions for using and administrating the bundle
Make sure to have installed Node 18 (or Node 14 for Sulu versions <2.6.0) for building the Sulu administration UI.
- Open a command console, enter your project directory and execute:
composer require robole/sulu-ai-translator-bundle
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
routes_admin.yaml
:
SuluAiTranslatorBundle:
resource: "@SuluAiTranslatorBundle/Resources/config/routes_admin.yml"
- 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
.env
file:
DEEPL_API_KEY="..."
(7. @todo Grant permissions in Sulu backend)
- Currently 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 first and undo changes
- Most of the frontend code uses React and is Sulu-compatible. Some actions, however, rely on
document.querySelector
- Add to
repositories
section ofcomposer.json
:
"repositories": [
{
"type": "path",
"url": "./../../../SuluAITranslatorBundle"
}
],
- Install bundle:
composer require robole/sulu-ai-translator-bundle:@dev
If a translation request fails, make sure that the source
and target
language keys are supported by DeepL. If not, extend TranslationController->getLanguageKey()
.
- LICENSE
- Find a less verbose way to wrap sulu core input components and toggle blocks.
- Enable configuration of translation strictness (e.g. formal, informal, etc.)
- Add a dropdown on translation button (see wireframe) to precisely define source and target language