|
| 1 | +--- |
| 2 | +description: With the automated translation add-on, users can translate content items into multiple languages with Google Translate and other machine translation engines. |
| 3 | +--- |
| 4 | + |
| 5 | +# Automated content translation |
| 6 | + |
| 7 | +The automated translation add-on package allows users have content items machine-translated into multiple languages by using external translation engines like Google Translate and DeepL. |
| 8 | +The package integrates with [[= product_name =]], and allows users to [request from the UI]([[= user_doc =]]/content_management/translate_content.md#add-translations) that a content item is translated. |
| 9 | +However, you can also run an API command to translate a specific content item. |
| 10 | +Either way, as a result, a new version of a content item is created with all [translatable fields](languages.md#translatable-and-untranslatable-fields) translated into a target language. |
| 11 | + |
| 12 | +## Configure automated content translation |
| 13 | + |
| 14 | +### Install package |
| 15 | + |
| 16 | +Automated content translation support comes as an additional package that needs to be downloaded and installed separately: |
| 17 | + |
| 18 | +```bash |
| 19 | +composer require ibexa/automated-translation |
| 20 | +``` |
| 21 | + |
| 22 | +!!! caution "Modify the default configuration" |
| 23 | + |
| 24 | + Flex installs and activates the package. |
| 25 | + However, you must modify the `bundles.php` file to change the template loading order: |
| 26 | + |
| 27 | + ```php |
| 28 | + <?php |
| 29 | + |
| 30 | + return [ |
| 31 | + ... |
| 32 | + Ibexa\Bundle\AutomatedTranslation\IbexaAutomatedTranslationBundle::class => ['all' => true], |
| 33 | + Ibexa\Bundle\AdminUi\IbexaAdminUiBundle::class => ['all' => true], |
| 34 | + ... |
| 35 | + ]; |
| 36 | + ``` |
| 37 | + |
| 38 | +### Configure automated content translation |
| 39 | + |
| 40 | +Before you can start using the feature you must get access to your Google and/or DeepL account. |
| 41 | + |
| 42 | +1\. Get the [Google API key](https://developers.google.com/maps/documentation/javascript/get-api-key) and/or [DeepL Pro key](https://support.deepl.com/hc/en-us/articles/360020695820-API-Key-for-DeepL-s-API). |
| 43 | + |
| 44 | +3\. Set these values in the YAML configuration files, under the `ibexa_automated_translation.system.default.configurations` key: |
| 45 | + |
| 46 | +``` yaml |
| 47 | +ibexa_automated_translation: |
| 48 | + system: |
| 49 | + default: |
| 50 | + configurations: |
| 51 | + google: |
| 52 | + apiKey: "google-api-key" |
| 53 | + deepl: |
| 54 | + authKey: "deepl-pro-key" |
| 55 | +``` |
| 56 | +
|
| 57 | +!!! note |
| 58 | +
|
| 59 | + The configuration is SiteAccess-aware, therefore, you can configure different engines to be used for different sites. |
| 60 | +
|
| 61 | +## Translate content items with API |
| 62 | +
|
| 63 | +To create a machine translation of a specific content item, run the following command: |
| 64 | +
|
| 65 | +```shell |
| 66 | +php bin/console ibexatranslate [contentId] [serviceName] --from=eng-GB --to=fre-FR |
| 67 | +``` |
| 68 | + |
| 69 | +## Add a custom machine translation service |
| 70 | + |
| 71 | +You can configure the automated translation package to use a custom machine translation service. |
| 72 | +You would do it, for example, when a new service emerges on the market, or your company requires that a specific service is used. |
| 73 | + |
| 74 | +To add a custom engine to a list of available translation services, do the following: |
| 75 | + |
| 76 | +- create a service that implements the ` Ibexa\AutomatedTranslation\Client\ClientInterface` |
| 77 | +- implement the `translate` method |
| 78 | +- in `services.yaml` file, tag the service as `ibexa.automated_translation.client` |
0 commit comments