Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-7912: Describe automated translation feature #2414

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
}
],
"require-dev": {
"ibexa/code-style": "^1.0",
"friendsofphp/php-cs-fixer": "^3.30",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-symfony": "^1.3",
"ibexa/doctrine-schema": "5.0.x-dev",
Expand Down
86 changes: 86 additions & 0 deletions docs/multisite/languages/automated_translations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
---

Check warning on line 1 in docs/multisite/languages/automated_translations.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/multisite/languages/automated_translations.md#L1

[Ibexa.ReadingLevel] The grade level is 8.52. Aim for 8th grade or lower by using shorter sentences and words.
Raw output
{"message": "[Ibexa.ReadingLevel] The grade level is 8.52. Aim for 8th grade or lower by using shorter sentences and words.", "location": {"path": "docs/multisite/languages/automated_translations.md", "range": {"start": {"line": 1, "column": 1}}}, "severity": "WARNING"}
description: With the automated translation add-on, users can translate content items into multiple languages with Google Translate or DeepL.
---

# Automated content translation

The automated translation add-on package allows users have content items machine-translated into multiple languages by using either Google Translate or DeepL external translation engine.
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.
However, you can also run an API command to translate a specific content item.
Either way, as a result, a new version of the content item is created, with the following elements translated into a target language:


- for pages: blocks that have the `text` or `richtext` [block attributes](../../content_management/pages/page_block_attributes/#block-attribute-types)

Check warning on line 13 in docs/multisite/languages/automated_translations.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/multisite/languages/automated_translations.md#L13

[Ibexa.EOLWhitespace] Remove whitespace characters from the end of the line.
Raw output
{"message": "[Ibexa.EOLWhitespace] Remove whitespace characters from the end of the line.", "location": {"path": "docs/multisite/languages/automated_translations.md", "range": {"start": {"line": 13, "column": 151}}}, "severity": "WARNING"}
- for other content types: Fields of the [TextLine](../../content_management/field_types/field_type_reference//textlinefield.md) and [RichText](../../content_management/field_types/field_type_reference//richtextfield.md) type

!!! note "DeepL limitations"

At this point a list of languages available when using DeepL is limited to English, German, French, Spanish, Italian, Dutch, Polish and Japanese.

## Configure automated content translation

### Install package

Automated content translation support comes as an additional package that you must download and install separately:

```bash
composer require ibexa/automated-translation
```

!!! caution "Modify the default configuration"

Symfony Flex installs and activates the package.
However, you must modify the `config/bundles.php` file to change the template loading order:

```php
<?php

return [
...
Ibexa\Bundle\AutomatedTranslation\IbexaAutomatedTranslationBundle::class => ['all' => true],
Ibexa\Bundle\AdminUi\IbexaAdminUiBundle::class => ['all' => true],
...
];
```

### Configure access to translation services

Before you can start using the feature you must configure access to your Google and/or DeepL account.

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).

3\. Set these values in the YAML configuration files, under the `ibexa_automated_translation.system.default.configurations` key:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't there be 2 here :)


``` yaml
ibexa_automated_translation:
system:
default:
configurations:
google:
apiKey: "google-api-key"
deepl:
authKey: "deepl-pro-key"
```

!!! note

The configuration is SiteAccess-aware, therefore, you can configure different engines to be used for different sites.

## Translate content items with CLI

To create a machine translation of a specific content item, run the following command:

```shell
php bin/console ibexa:automated:translate [contentId] [serviceName] --from=eng-GB --to=fre-FR
```
Comment on lines +73 to +75
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO we can add full synopsis here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mnocon Please take over.


## Add a custom machine translation service

By default, the automated translation package can connect to Google Translate or DeepL, but you can configure it to use a custom machine translation service.
You would do it, for example, when a new service emerges on the market, or your company requires that a specific service is used.

To add a custom engine to a list of available translation services, do the following:

1. Create a service that implements ` Ibexa\AutomatedTranslation\Client\ClientInterface`
1. Implement the `translate` method
1. In `services.yaml` file, tag the service as `ibexa.automated_translation.client`
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ nav:
- Languages: multisite/languages/languages.md
- Language API: multisite/languages/language_api.md
- Back Office translations: multisite/languages/back_office_translations.md
- Automated content translation: multisite/languages/automated_translations.md
- Permissions:
- Permissions: permissions/permissions.md
- Permission overview: permissions/permission_overview.md
Expand Down
Loading