diff --git a/code_samples/multisite/automated_translation/config/services.yaml b/code_samples/multisite/automated_translation/config/services.yaml deleted file mode 100644 index 85bdd6f69e6..00000000000 --- a/code_samples/multisite/automated_translation/config/services.yaml +++ /dev/null @@ -1,31 +0,0 @@ -services: - # default configuration for services in *this* file - _defaults: - autowire: true # Automatically injects dependencies in your services. - autoconfigure: true # Automatically registers your services as commands, event subscribers, etc. - - # makes classes in src/ available to be used as services - # this creates a service per class whose id is the fully-qualified class name - App\: - resource: '../src/' - exclude: - - '../src/DependencyInjection/' - - '../src/Entity/' - - '../src/Kernel.php' - - App\AutomatedTranslation\AiClient: - tags: - - ibexa.automated_translation.client - - App\AutomatedTranslation\ImageFieldEncoder: - tags: - - ibexa.automated_translation.field_encoder - -ibexa_automated_translation: - system: - default: - configurations: - aiclient: - languages: - - 'en_GB' - - 'fr_FR' diff --git a/code_samples/multisite/automated_translation/src/AutomatedTranslation/AiClient.php b/code_samples/multisite/automated_translation/src/AutomatedTranslation/AiClient.php deleted file mode 100644 index 2c5b41f31b8..00000000000 --- a/code_samples/multisite/automated_translation/src/AutomatedTranslation/AiClient.php +++ /dev/null @@ -1,64 +0,0 @@ - */ - private array $supportedLanguages; - - public function __construct( - private readonly ActionServiceInterface $actionService, - private readonly ActionConfigurationServiceInterface $actionConfigurationService - ) { - } - - public function setConfiguration(array $configuration): void - { - if (!array_key_exists('languages', $configuration)) { - throw new ClientNotConfiguredException('List of supported languages is missing in the configuration under the "languages" key'); - } - $this->supportedLanguages = $configuration['languages']; - } - - public function translate(string $payload, ?string $from, string $to): string - { - $action = new TranslateAction(new Text([$payload])); - $action->setRuntimeContext( - new RuntimeContext( - [ - 'from' => $from, - 'to' => $to, - ] - ) - ); - $actionConfiguration = $this->actionConfigurationService->getActionConfiguration('translate'); - $actionResponse = $this->actionService->execute($action, $actionConfiguration)->getOutput(); - - assert($actionResponse instanceof Text); - - return $actionResponse->getText(); - } - - public function supportsLanguage(string $languageCode): bool - { - return in_array($languageCode, $this->supportedLanguages, true); - } - - public function getServiceAlias(): string - { - return 'aiclient'; - } - - public function getServiceFullName(): string - { - return 'Custom AI Automated Translation'; - } -} diff --git a/code_samples/multisite/automated_translation/src/AutomatedTranslation/ImageFieldEncoder.php b/code_samples/multisite/automated_translation/src/AutomatedTranslation/ImageFieldEncoder.php deleted file mode 100644 index 675b9144316..00000000000 --- a/code_samples/multisite/automated_translation/src/AutomatedTranslation/ImageFieldEncoder.php +++ /dev/null @@ -1,39 +0,0 @@ -fieldTypeIdentifier === 'ibexa_image'; - } - - public function canDecode(string $type): bool - { - return $type === 'ibexa_image'; - } - - public function encode(Field $field): string - { - /** @var \Ibexa\Core\FieldType\Image\Value $value */ - $value = $field->getValue(); - - return $value->alternativeText ?? ''; - } - - /** - * @param string $value - * @param \Ibexa\Core\FieldType\Image\Value $previousFieldValue - */ - public function decode(string $value, $previousFieldValue): Value - { - $previousFieldValue->alternativeText = $value; - - return $previousFieldValue; - } -} diff --git a/code_samples/multisite/automated_translation/src/AutomatedTranslation/TranslateAction.php b/code_samples/multisite/automated_translation/src/AutomatedTranslation/TranslateAction.php deleted file mode 100644 index 8d2e14c74d3..00000000000 --- a/code_samples/multisite/automated_translation/src/AutomatedTranslation/TranslateAction.php +++ /dev/null @@ -1,13 +0,0 @@ - ['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-API). - -2\. Set these values in the YAML configuration files, under the `ibexa_automated_translation.system.default.configurations` key: - -``` yaml -ibexa_automated_translation: - system: - default: - configurations: - google: - apiKey: "google-api-key" - deepl: - authKey: "deepl-pro-key" -``` - -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, you can use the `ibexa:automated:translate` command. - -The following arguments and options are supported: - -- `--from` - the source language -- `--to` - the target language -- `contentId` - ID of the content to translate -- `serviceName` - the service to use for translation - -For example, to translate the root content item from English to French with the help of Google Translate, run: - -``` bash -php bin/console ibexa:automated:translate --from=eng-GB --to=fre-FR 52 google -``` - -## Extend automated content translations - -### 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. - -The following example adds a new translation service. -It uses the [AI actions framework](ai_actions.md) and assumes a custom `TranslateAction` AI Action exists. -To learn how to build custom AI actions see [Extending AI actions](extend_ai_actions.md#custom-action-type-use-case). - -1. Create a service that implements the [`\Ibexa\AutomatedTranslation\Client\ClientInterface`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-AutomatedTranslation-Client-ClientInterface.html) interface: - -``` php hl_lines="31-48" -[[= include_code('code_samples/multisite/automated_translation/src/AutomatedTranslation/AiClient.php') =]] -``` - -2\. Tag the service as `ibexa.automated_translation.client` in the Symfony container: - -``` yaml -[[= include_file('code_samples/multisite/automated_translation/config/services.yaml', 15, 18) =]] -``` - -3\. Specify the configuration under the `ibexa_automated_translation.system.default.configurations` key: - -``` yaml -[[= include_file('code_samples/multisite/automated_translation/config/services.yaml', 23, 32) =]] -``` - -### Create custom field or block attribute encoder - -You can expand the list of supported field types and block attributes for automated translation, adding support for even more use cases than the ones built into [[= product_name =]]. - -The whole automated translation process consists of 3 phases: - -1. **Encoding** - data is extracted from the field types and block attributes and serialized into XML format -1. **Translating** - the serialized XML is sent into specified translation service -1. **Decoding** - the translated response is deserialized into the original data structures for storage in [[= product_name =]] - -The following example adds support for automatically translating alternative text in image fields. - -1. Create a class implementing the [`FieldEncoderInterface`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-AutomatedTranslation-Encoder-Field-FieldEncoderInterface.html) and add the required methods: - -``` php hl_lines="11-14 16-19 21-27 33-38" -[[= include_code('code_samples/multisite/automated_translation/src/AutomatedTranslation/ImageFieldEncoder.php') =]] -``` - -In this example, the methods are responsible for: - -- `canEncode` - deciding whether the field to be encoded is an [Image](imagefield.md) field -- `canDecode` - deciding whether the field to be decoded is an [Image](imagefield.md) field -- `encode` - extracting the alternative text from the field type -- `decode` - saving the translated alternative text in the field type's value object - -2\. Register the class as a service. -If you're not using [Symfony's autoconfiguration]([[= symfony_doc =]]/service_container.html#the-autoconfigure-option), use the `ibexa.automated_translation.field_encoder` service tag. - -``` yaml -[[= include_file('code_samples/multisite/automated_translation/config/services.yaml', 19, 22) =]] -``` - -For custom block attributes, the appropriate interface is [`BlockAttributeEncoderInterface`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-AutomatedTranslation-Encoder-BlockAttribute-BlockAttributeEncoderInterface.html) and the service tag is `ibexa.automated_translation.block_attribute_encoder`. diff --git a/docs/multisite/translations_management/translations_management_guide.md b/docs/multisite/translations_management/translations_management_guide.md index f01b85c7cab..3062385e203 100644 --- a/docs/multisite/translations_management/translations_management_guide.md +++ b/docs/multisite/translations_management/translations_management_guide.md @@ -21,14 +21,6 @@ The package integrates with the [AI Actions framework](ai_actions_guide.md) to s Administrators can manage providers and configure default provider-to-language-pair mappings directly in [[= product_name =]]'s back office, while editors can trigger machine translation from the content editing interface. -!!! note - - Translations management is a standalone set of features. - Although some views are similar to those delivered by the [Automated translations](automated_translations.md) opt-in package, Translations management does not require the `ibexa/automated-translation` package to run. - These two packages use different namespaces, service tags, and provider interfaces. - - If you're currently using Automated translations, consider migrating to Translations management. - ## Availability Translations management is an opt-in capability available as an [LTS Update](editions.md#lts-updates) for all [[= product_name =]] editions, starting with the v5.0.10 version. @@ -77,7 +69,7 @@ Editors can: Content types that are editable in [Page builder](page_builder_guide.md) or [Form builder](form_builder_guide.md) are excluded from side-by-side editing. - Products are editable in the side-by-side view, but [product attributes aren;t translatable](products.md#product-attributes). + Products are editable in the side-by-side view, but [product attributes aren't translatable](products.md#product-attributes). ### Command-line translation diff --git a/docs/release_notes/cohesivo_v6.0_deprecations.md b/docs/release_notes/cohesivo_v6.0_deprecations.md index 20d9d62bcd3..441e7ba09b0 100644 --- a/docs/release_notes/cohesivo_v6.0_deprecations.md +++ b/docs/release_notes/cohesivo_v6.0_deprecations.md @@ -26,10 +26,17 @@ This page lists backwards compatibility breaks introduced in Cohesivo v6.0. ## Removed packages -The `ibexa/app-switcher` package, and its `IbexaAppSwitcherBundle`, is no longer part of the 6.0. +- The `ibexa/app-switcher` package, and its `IbexaAppSwitcherBundle`, is no longer part of the 6.0. +- The `ibexa/automated-translation` package is no longer available as an opt-in. Use [Translations management](configure_translations_management.md) instead. ## PHP API changes +### ibexa/automated-translations + +| Deprecated since | Entity | Change | +| --- |---------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| v5.0.10 | `\Ibexa\Contracts\AutomatedTranslation` | The `ibexa/automated-translation` package is replaced by `ibexa/translations-management`. For Translations management API, see [`Ibexa\Contracts\TranslationsManagement`](/api/php_api/php_api_reference/namespaces/ibexa-contracts-translationsmanagement.html). | + ### ibexa/http-cache | Deprecated since | Entity | Change | diff --git a/mkdocs.yml b/mkdocs.yml index 989d7a1d4ef..7e1372683de 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -484,7 +484,6 @@ 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 - Translations management: - Translations management: multisite/translations_management/translations_management.md - Translations management guide: multisite/translations_management/translations_management_guide.md diff --git a/plugins.yml b/plugins.yml index d00dcacd7bc..bc715938dd3 100644 --- a/plugins.yml +++ b/plugins.yml @@ -624,6 +624,7 @@ plugins: 'cdp/cdp_activation/cdp_configuration.md': 'raptor_cdp/raptor_cdp_activation/raptor_cdp_configuration.md' 'cdp/cdp_activation/cdp_data_export.md': 'raptor_cdp/raptor_cdp_activation/raptor_cdp_data_export.md' 'cdp/cdp_activation/cdp_add_tracking.md': 'raptor_cdp/raptor_cdp_activation/raptor_cdp_add_tracking.md' + 'multisite/languages/automated_translations.md': 'multisite/translations_management/configure_translations_management.md' - llmstxt: diff --git a/tools/api_refs/api_refs.sh b/tools/api_refs/api_refs.sh index 4f56e6d294b..7c3bba8647c 100755 --- a/tools/api_refs/api_refs.sh +++ b/tools/api_refs/api_refs.sh @@ -11,7 +11,7 @@ REST_API_OPENAPI_FILE_JSON=${5:-./docs/api/rest_api/rest_api_reference/openapi.j DXP_EDITION='commerce'; # Edition from and for which the Reference is built DXP_VERSION="${DXP_VERSION:-6.0.*}"; # Version from and for which the Reference is built; can be overridden by the DXP_VERSION env var (e.g. v5.0.x-dev for a dev build) -DXP_ADD_ONS=(automated-translation rector integrated-help fieldtype-richtext-rte connector-anthropic connector-gemini shopping-list cdp connector-raptor connector-quable mcp); # Packages not included in $DXP_EDITION but added to the Reference, listed without their vendor "ibexa" +DXP_ADD_ONS=(rector integrated-help fieldtype-richtext-rte connector-anthropic connector-gemini shopping-list cdp connector-raptor connector-quable mcp); # Packages not included in $DXP_EDITION but added to the Reference, listed without their vendor "ibexa" DXP_EDITIONS=(oss headless experience commerce); # Available editions ordered by ascending capabilities SF_VERSION='7.4'; # Symfony version used by Ibexa DXP PHPDOC_VERSION='3.10.0'; # Version of phpDocumentor used to build the Reference