Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

WordPress 6.7 has introduced a new issue that impact translations, please update WooCommerce and WPML to the latest versions before you report issues. More about this here - https://wpml.org/errata/php-error-wp-6-7-notice-function-_load_textdomain_just_in_time-was-called/
Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 13:00 9:00 – 13:00 9:00 – 13:00 8:00 – 12:00 8:00 – 12:00 -
- 14:00 – 17:00 14:00 – 18:00 14:00 – 18:00 13:00 – 17:00 13:00 – 17:00 -

Supporter timezone: Europe/Zagreb (GMT+01:00)

This topic contains 2 replies, has 0 voices.

Last updated by Bruno Kos 9 hours, 9 minutes ago.

Assisted by: Bruno Kos.

Author Posts
November 27, 2024 at 7:24 am #16447629

dorM

Background of the issue:
I am trying to translate ACF select field values using WPML but can't find a solution anywhere.

Symptoms:
In the field 'dough', I expected to see translated values from string translation, but instead, I got the original language values.

Questions:
How can I translate ACF select field values?
Why are the original language values appearing instead of the translated ones?

November 27, 2024 at 8:50 am #16448095

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+01:00)

Hi,

Thank you for contacting WPML support!

Did you check this?
https://wpml.org/documentation/related-projects/translate-sites-built-with-acf/translating-acf-field-labels-with-wpml/

If so, can you tell me what did you try and after which step does it still fail?

Regards,
Bruno Kos

November 27, 2024 at 9:16 am #16448225

dorM

yes, i tried both ways -
when using Same fields across languages, fields not shown on page translation.
when using Different fields across languages, i translated using string translation, but translations values not shown on frontend.

November 27, 2024 at 2:53 pm #16450680

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+01:00)

Would you be willing to provide me with WordPress credentials so I could investigate the issue directly?

Also send me the URL where this occurs.

https://wpml.org/purchase/support-policy/privacy-and-security-when-providing-debug-information-for-support/

I marked your next reply as private so that you can safely add credentials.

November 29, 2024 at 7:29 am #16457869

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+01:00)

So, the dropdown translation works, but it doesn't function correctly within the modal?

Could you clarify where the modal is being generated? It seems the modal isn't properly filtering these values. This could either be due to missing code specific to the modal (if it's only pulling ACF fields) or a compatibility issue with the plugin managing the modal.

dough is properly translated.jpg
only not working modal.jpg
December 1, 2024 at 8:56 am #16462662

dorM

no its not in the filter.
look at the attachments
hidden link

CleanShot 2024-12-01 at 10.54.55.png
CleanShot 2024-12-01 at 10.55.40.png
December 2, 2024 at 8:39 am #16464572

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+01:00)

I see, but the code that creates the popup itself and then pulls these custom fields, where is this coded?

Is it your custom code or part of the Bakery elements/custom widgets?

December 2, 2024 at 1:36 pm #16466309

dorM

its custom coded.

December 2, 2024 at 3:45 pm #16467361

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+01:00)

Can you tell where in the theme code or plugin code can we find the code reponsible for it? Perhaps it is where WPML filters are missing that would filter the content based on the language.

December 2, 2024 at 4:07 pm #16467446

dorM

yes of course but you can see in the edit screen in the english version that the values are not shown as translated at all.

anyways, this is the code responsible for showing it on frontend:
page-our-products.php

take a look in the products() function
all data is translated except for the "dough" field

December 3, 2024 at 6:24 am #16469446

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+01:00)

Can you please try the following:

Update the `products()` function in the `page-our-products.php` file by replacing the current implementation of `get_field('dough', $product->ID)` with the following code:

 $current_language = apply_filters('wpml_current_language', null);
   $translated_product_id = apply_filters('wpml_object_id', $product->ID, 'product', true, $current_language);
   $dough = get_field('dough', $translated_product_id);

Does it work?

December 3, 2024 at 7:21 am #16469613

dorM

hi, thank you.
but it is still returning in hebrew - "אפוי - קפוא"

implemented it like this:
$products = get_posts([
'post_type' => 'product',
'numberposts' => -1,
'post_status' => 'publish',
'suppress_filters' => false,
]);
$products = array_map(function ($product) {
$current_language = apply_filters('wpml_current_language', null);
$translated_product_id = apply_filters('wpml_object_id', $product->ID, 'product', true, $current_language);

return [
'id' => $product->ID,
'title' => $product->post_title,
'image' => get_the_post_thumbnail_url($product->ID) ? get_the_post_thumbnail_url($product->ID) : esc_url(get_field('site_product_default_image', 'options')),
'categories' => wp_get_post_terms($product->ID, 'product_category', ['fields' => 'all']),
'description' => $product->post_content,
'acf' => array(
'catalog_number' => get_field('catalog_number', $product->ID),
// 'parve_milk' => get_field('parve_milk', $product->ID) ? 'חלבי' : 'פרווה',
'weight_units' => get_field('weight_units', $product->ID) ? __('משקל', 'rustic') : __('יחידה', 'rustic'),
'is_weight_units' => get_field('weight_units', $product->ID),
'dough' => get_field('dough', $translated_product_id),
'ammount_karton' => get_field('ammount_karton', $product->ID),
'units_weight' => get_field('units_weight', $product->ID),
'relatedProducts' => get_field('related_products', $product->ID),
'single_product_comment' => get_field('single_product_comment', $product->ID),
),
];
}, $products);

-------
$current_language return en
$translated_product_id returns id

December 3, 2024 at 10:52 am #16471056

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+01:00)

In the ACF Field Group settings for the dough field, can you try changing the return format to "Label" instead of "Value"?

Currently, it is configured to return the value, which means the get_field call is retrieving the value, not the label. Labels in choice fields, like Select fields, are translatable, whereas values are not.

Screenshot.png