You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, you must modify the `config/bundles.php` file to change the bundle loading order so that`IbexaAutomatedTranslationBundle` is before `IbexaAdminUiBundle`:
35
+
However, you must modify the `config/bundles.php` file to change the bundle loading order so tha `IbexaAutomatedTranslationBundle` is loaded before `IbexaAdminUiBundle`:
40
36
41
37
```php
42
38
<?php
@@ -72,33 +68,78 @@ The configuration is SiteAccess-aware, therefore, you can configure different en
72
68
73
69
## Translate content items with CLI
74
70
75
-
To create a machine translation of a specific content item, run the following command:
71
+
To create a machine translation of a specific content item, you can use the `ibexa:automated:translate` command.
72
+
73
+
The following arguments and options are supported:
- `serviceName`- the service to use for translation
79
+
80
+
For example, to translate the root content item from the English translation into French with the help of Google Translate, run:
81
+
82
+
``` bash
83
+
php bin/console ibexa:automated:translate --from=eng-GB --to=fre-FR 52 google
79
84
```
80
85
81
-
## Add a custom machine translation service
86
+
## Extend automated content translations
87
+
88
+
### Add a custom machine translation service
82
89
83
90
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.
84
91
You would do it, for example, when a new service emerges on the market, or your company requires that a specific service is used.
85
92
86
-
To add a custom engine to a list of available translation services, do the following:
93
+
The following example adds a new translation service.
94
+
It uses the [AI actions framework](ai_actions_md) and assumes a custom `TranslateAction` AI Action exists.
95
+
To learn how to build custom AI actions see [Extending AI actions](extend_ai_actions.md#custom-action-type-use-case).
87
96
88
97
1. Create a service that implements the [`\Ibexa\AutomatedTranslation\Client\ClientInterface`](REFERENCE LINK) interface
89
-
1. In `services.yaml` file, tag the service as `ibexa.automated_translation.client`
### Create custom field or block attribute encoder
92
116
93
-
<examplehere>
117
+
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 =]].
94
118
95
119
The whole automated translation process consists of 3 phases:
96
-
1. Encoding - the raw data stored in the fieldtype is processed so that it can be translated by the automated translation service. Google and Deepl can h
97
-
1. Translating - the data is translated using an Automated Translatin client.
98
-
1. Decoding - the translated data is decoded back to the original structure so that it can be stored back in [= product_name =]]
99
120
100
-
## Add a custom field or block encoder
121
+
1. **Encoding** - data is extracted from the field types and block attributes and serialized into XML format
122
+
1. **Translating** - the serialized XML is sent into specified translation service
123
+
1. **Decoding** - the translated response is deserialized into the original data structures for storage in [[= product_name =]]
101
124
125
+
The following example adds support for automatically translating alternative text in image fields by using the [AI Actions](ai_actions.md).
102
126
127
+
1. Create a class implementing the [`FieldEncoderInterface`](TODO:Referencelink) and add the required methods:
- `canEncode`- deciding if the field to be encoded is an [Image](imagefield.md) field.
135
+
- `canDecode`- deciding if the field to be decoded is an [Image](imagefield.md) field.
136
+
- `encode`- extracting the alternative text from the field type.
137
+
- `decode`- saving the translated alternative text in the field type's value object.
138
+
139
+
2\. Register it 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.
For custom block attributes the appropriate interface is [`BlockAttributeEncoderInterface`](TODO: Reference link) and the service tag is `ibexa.automated_translation.block_attribute_encoder`.
0 commit comments