Description
This extension ( to be used with the DeepL plugin for WordPress ) allows you :
- to translate custom fields : WordPress custom fields, ACF fields
- to translate the SEO slug
- to translate WooCommerce Products
- to translate all Posts types in batches.
- to upload and use Glossaries.
Target languages: all languages available on DeepL.
Configuration: in Settings / Translation DeepL, go to the “Advanced” tab
This plugin is not a multilingual manager. If you display multiple languages on your website, it is advised to install a management plugin (like Polylang, Weglot, TranslatePress, etc.)
Compatible with Polylang, ACF, Metabox
Documentation
La plupart des réglages se trouvent sur la page Réglages / Traduction Deepl : onglet “Pro”
En utilisant Polylang pour traduire par lots, si vous souhaitez créer les nouveaux posts directement, n’oubliez pas de cocher “Créer de nouveaux posts” sur le réglage “Que faire pour les traductions en masse ? ”
Si vous avez des données métas très spécifiques (encodées JSON, sérialisées, etc.), voici le code à ajouter dans votre theme/functions.php pour ajouter les valeurs à traduire avant traduction, et les récupérer et les sauvegarder après traduction :
/**
*
* To add specific data / unique custom meta to the translation, add this code to your theme/functions.php
* Sample : the metakey is 'hotelwp_meta' and the value is encoded in json, we need to translate 'tagline' and 'alt_title' from the array of data
* */
/**
* First add the original strings to the array to be translated
* */
add_filter( ‘deepl_translate_post_link_strings’, ‘mytheme_deeplpro_translate_post_link_strings’, 80, 4 );
function mytheme_deeplpro_translate_post_link_strings( $strings_to_translate, $WP_Post, $target_lang, $source_lang ) {
$custom_data = json_decode( get_post_meta( $WP_Post->ID, ‘hotelwp_meta’, true ), true );
if( !empty( $custom_data[‘tagline’] ) ) {
$strings_to_translate[‘mytheme_tagline’] = $custom_data[‘tagline’];
}
if( !empty( $custom_data[‘alt_title’] ) ) {
$strings_to_translate[‘mytheme_alt_title’] = $custom_data[‘alt_title’];
}
return $strings_to_translate;
}
/**
* Then get the translated data after translation and post update
*/
add_action( ‘deepl_translate_after_post_update’, ‘mytheme_deeplpro_translate_post_link_after’, 80, 5 );
function mytheme_deeplpro_translate_post_link_after( $post_array, $strings_to_translate, $response, $WP_Post, $no_translation ) {
$new_post_custom_data = json_decode( get_post_meta( $WP_Post->ID, ‘hotelwp_meta’, true), true );
$changed = false;
if( $response[‘translations’] ) foreach( $response[‘translations’] as $key => $translation ) {
if( substr( $key, 0, 8 ) == ‘mytheme_’ ) {
$real_key = substr( $key, 8 );
$new_post_custom_data[$real_key] = $translation;
$changed = true;
}
}
if( $changed ) {
update_post_meta( $WP_Post->ID, ‘hotelwp_meta’, json_encode( $new_post_custom_data, JSON_UNESCAPED_UNICODE ) );
}
}
Gamecodecity –
Does it work with Yoast Seo titles and description? Free version is now working.
Malaiac –
Yes, the Pro version translates Yoast data