Sauter la navigation

Ce sujet contient 0 réponse, a 1 voix.

Dernière mise à jour par tarmoV Il y a 5 mois.

Assisté par: Waqas Bin Hasan.

Auteur Articles
Septembre 16, 2024 à 8:00 am #16181911

tarmoV

Background of the issue:
I am developing a site and using WPML for translations. I have created a function in my functions.php file to output ACF select dropdown data to my WooCommerce single product page. The function includes translations for certain fields based on the current language.

function add_shortcode_before_short_description(){
echo '' . get_the_title() . '';
echo get_field('text_area');

$puuliik = get_field('puutype');
echo '' . esc_html__('Puuliik:', 'puidukoda') . ' ' . ($puuliik ? $puuliik : 'WW') . '';

$pinnas = get_field('surface');
if ($pinnas):
// Get the current language
$current_language = apply_filters('wpml_current_language', NULL);

// Translate based on the value of $pinnas
$translations = array(
'Fine planed' => array(
'en' => esc_html__('Fine planed', 'puidukoda'),
'et' => esc_html__('Hööveldatud', 'puidukoda'),
),
'Sawn' => array(
'en' => esc_html__('Sawn', 'puidukoda'),
'et' => esc_html__('Peensaetud', 'puidukoda'),
),
'Micro rifled' => array(
'en' => esc_html__('Micro rifled', 'puidukoda'),
'et' => esc_html__('Rihveldatud', 'puidukoda'),
),
);

// Default to English if language is not handled
$translated_pinnas = isset($translations[$pinnas][$current_language]) ? $translations[$pinnas][$current_language] : $pinnas;

echo '' . esc_html__('Pinnatöötlus:', 'puidukoda') . ' ' . $translated_pinnas . '';
else:
echo '' . esc_html__('Pinnatöötlus:', 'puidukoda') . ' ' . esc_html__('Hööveldatud', 'puidukoda') . '';
endif;
}
add_action( 'woocommerce_single_product_summary', 'add_shortcode_before_short_description', 14, 1 );

Symptoms:
The WPML string translation doesn't work for the specific case of translating the 'surface' field. Other string translations work as expected.

Questions:
Can you assist in what the issue could be here for this certain case?

View link: lien caché
(should be EN language code)