Need assistance with translation of product names
-
Hi team,
I hope you all are having a great day.
This is Pratik from the Funnelkit Support team. We are reaching out to get some information from you.
We have a product called Funnelkit Automation, which helps customers automate their pre & post-purchase email flows and offers them some CRM capabilities.
FKA has an abandoned cart feature that fetches the product names from the cart/checkout page and prints them in the email. We use Woo’s get_name() function for it. One of our mutual customers is using both plugins and is facing an issue with the translation of the product name.
Their site’s base language is FRENCH, and they also have an additional language, German & they are using the TranslatePress plugin. The checkout page correctly shows the product name as per the language, however when we try to fetch it in our email, even though customer abandons from the German checkout page, the FRENCH product name gets printed in the email.
French checkout page -> https://greenbeautysquare.com/boutique/concentre-hydratation-hydraboost/
German checkout page -> https://greenbeautysquare.com/de/shop/hydraboost-feuchtigkeitskonzentrat-gel/
When we fetch the product name from German checkout page, if prints the value shown in the French checkout page.
To overcome this issue, we have written a snippet as given below,function get_translated_string( $string, $language ) {
if ( empty( $string ) || empty( $language ) ) {
return $string;
}
if ( class_exists( 'TRP_Translate_Press' ) ) {
$trp = TRP_Translate_Press::get_trp_instance();
$settings = $trp->get_component( 'settings' );
$settings = $settings->get_settings();
$default_language = $settings['default-language'];
if ( $language === $default_language ) {
return $string;
}
global $wpdb;
$table = strtolower( "{$wpdb->prefix}trp_dictionary_{$default_language}_{$language}" );
BWFAN_Common::pr( $table );
$query = "SELECTtranslated
FROM {$table} WHEREoriginal
='$string'";
BWFAN_Common::pr( $query );
$value = $wpdb->get_var( $query );
return empty( $value ) ? $string : $value;
}
return $string;
}We wanted your opinion to see if this is correct or if you have any better idea. We are looking forward to your response.
The page I need help with: [log in to see the link]
- You must be logged in to reply to this topic.