Bulk text translation with DeepL?
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Bulk text translation with DeepL?
Hi,
with "AI-based text translation" DeepL translation of single text elemets is possible.
found here https://aimeos.org/tips/aimeos-2019-10-lts-release/ and https://aimeos.org/docs/2023.x/config/a ... #translate
Is there also an option to translate multipe text elements at once / as batch?
eg. translation of all product names (about 3.000 text items) from DE to EN at once.
Thank you
with "AI-based text translation" DeepL translation of single text elemets is possible.
found here https://aimeos.org/tips/aimeos-2019-10-lts-release/ and https://aimeos.org/docs/2023.x/config/a ... #translate
Is there also an option to translate multipe text elements at once / as batch?
eg. translation of all product names (about 3.000 text items) from DE to EN at once.
Thank you
Re: Bulk text translation with DeepL?
No that's not possible out of the box and you have to write your own script to do that.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Bulk text translation with DeepL?
What would be the best way to create a script for the mass translation of product texts?
Load the relevant texts from the DB table (SQL) -> call DeepL-API -> write translation to the DB?
Which table should be considered?
Is there another method or function of Aimeos that can be used?
Thank you!
Load the relevant texts from the DB table (SQL) -> call DeepL-API -> write translation to the DB?
Which table should be considered?
Is there another method or function of Aimeos that can be used?
Thank you!
Re: Bulk text translation with DeepL?
Use the Aimeos text manager to iterate e.g. over all English texts, call the DeepL API and save the returned text as new text item:
https://aimeos.org/docs/latest/models/s ... fficiently
https://aimeos.org/docs/latest/models/s ... fficiently
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Bulk text translation with DeepL?
Hi,
I'm trying to translate all product texts with type = 'name' from DE to EN and ES via DeepL API.
Selecting the 'name' texts and calling the API works
but two questions remain:
1) How can I check if an EN or ES translation already exists?
-> Only product name texts without an EN OR ES translation should be selected
2) How can I add the translated text to the product item?
I checked https://aimeos.org/docs/latest/models/m ... reate-item , but couldn't get it to work
Thank you
I'm trying to translate all product texts with type = 'name' from DE to EN and ES via DeepL API.
Selecting the 'name' texts and calling the API works
Code: Select all
$productManager = \Aimeos\MShop::create( $this->context(), 'product' );
$filter = $productManager->filter();
$cursor = $productManager->cursor( $filter );
while( $items = $productManager->iterate( $cursor, ['text'] ) ) {
foreach ($items->getRefItems('text', 'name') as $textitems) {
foreach( $textitems as $entry ){
$text_source = $entry['text.content'];
echo($text_source);
}
}
/**
* get translation, call Deepl API
*/
$deepLy = new DeepLy(env('DEEPL_API_KEY'));
$text_translated_de = $deepLy->translate($text_source, 'DE');
$text_translated_es = $deepLy->translate($text_source, 'ES');
/**
* update product db entry, add transaltion to
*/
$items = $productManager->create();
$items->addListItem( 'text', 'name', $text_translated_de, );
$items = $productManager->save( $items );
}
1) How can I check if an EN or ES translation already exists?
-> Only product name texts without an EN OR ES translation should be selected
2) How can I add the translated text to the product item?
I checked https://aimeos.org/docs/latest/models/m ... reate-item , but couldn't get it to work
Thank you
Re: Bulk text translation with DeepL?
columbo wrote: ↑18 Dec 2023, 07:531) How can I check if an EN or ES translation already exists?Code: Select all
$items = $productManager->create(); $items->addListItem( 'text', 'name', $text_translated_de, ); $items = $productManager->save( $items );
-> Only product name texts without an EN OR ES translation should be selected
Code: Select all
$partitions = $productItem->getRefItems( 'text', 'name', 'default' )->partition( function( $item ) {
return $item->getLanguageId() === 'DE' ? 'DE' : 'tx';
} );
if( !$partitions->has( 'tx' ) ) {
$textItem = $partitions->get( 'DE' )->first();
// translate and add translation
}
https://aimeos.org/docs/latest/models/m ... ated-itemscolumbo wrote: ↑18 Dec 2023, 07:53 2) How can I add the translated text to the product item?
I checked https://aimeos.org/docs/latest/models/m ... reate-item , but couldn't get it to work
Code: Select all
$listItem = $productManager->createListItem();
$textItem = $textManager->create()->setType( 'name' )->setLanguageId( 'en' )->setContent( $text_translated_en );
$productItem->addListItem( 'text', $listItem, $textItem->setLabel( 'Text in EN' );
// ...
$productManager->save( $productItems );
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star