[Resolved] FacetWP and ACF issue with translation of checkbox choices
This thread is resolved. Here is a description of the problem and solution.
Problem:
FacetWP - translated checkbox labels are not rendered with shortcodes.
Steps to replicate the issue
The ACF phase
1. Create a field group and add a checkbox field to it.
2. In the Choices field, add at least one choice; for example like this boy : Boy.
3. Save the field group.
The WordPress phase
1. Create a post and select the checkbox's choices and publish the post.
The FacetWP phase
1. Go to Settings -> FacetWP.
2. Add a new Facet: Ensure to select Facet type = Checkbox and Data source = [Field group name] Field name.
3. Save and copy the shortcode.
The Elementor phase
1. Edit the post with Elementor.
2. Add a Shortcode element and insert the Facet shortcode.
3. Add a `Posts` element. And under the FacetWP section `Enable FacetWP`.
4. Save the changes.
The WPML phase
1. Translate the post with the Advanced Translation Editor.
2. Add translation to the checkbox labels, and complete the translation.
3. Check the translated post on the front end and see that the checkbox labels are not showing the translation.
A workaround solution:
1. Take a backup of your site in case something goes wrong.
2. Add the following function to the functions.php file of your theme and save the changes.
// WPML Workaround for compsupp-6751
function wpml_compsupp6751_translate_facet_display_value( $label, $args ) {
if ( class_exists('Sitepress') ) {
$wpml_default_lang = apply_filters('wpml_default_language', NULL );
$wpml_current_lang = apply_filters( 'wpml_current_language', NULL );
if ($wpml_default_lang == $wpml_current_lang ) {
do_action( 'wpml_register_single_string', 'FacetWP', 'Facet Display Value : '.substr($label, 0, 10), $label );
}
// Apply the translation to the string
$label = apply_filters('wpml_translate_single_string', $label , 'FacetWP', 'Facet Display Value : '.substr($label, 0, 10) );
}
return $label;
}
add_filter( 'facetwp_facet_display_value', 'wpml_compsupp6751_translate_facet_display_value', 10, 2 );
3. On the front end, visit the page with the ACF fields in the original language. This will register the strings into Strings Translation.
4. Go to WPML -> Strings Translation and filter to show the FacetWP domain. Under it, you will find the strings with the name "Facet Display Value : *name". Those will be the label of the checkbox strings. Translate them into the other language.
**** Important! Please make a full site backup (files and DB) before you proceed with those steps****
Our compatibility team has contacted the FacedWP plugin developers, and we are trying to cooperate with them to solve this issue.
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.
We use WPML, ACF and FacetWP on our website. Our issue is that when we switch the language from the original one to another, the filter options on the "products page" are displayed in the original language.
I've consulted my teammates regarding this issue. In other cases changing the "Return Value" of the field to "Label" instead of "Value" solved such an issue.
Can you please try it on your site and see if it helps?
Please disable and clear all the caching on your site when you try that.
thank you for your support.
I have changed the return value of "Dauer" (Duration) to "Label" ("Beschriftung") and checked it on the frontend. Unfortunately, it did not work (see screenshots).
I discussed this issue with our ACFML developer. And I also tried to replicate this issue on a test site but couldn't. Translation of checkbox labels works as far as we can see. But in your case, other plugins are involved. I checked your staging site and edited the homepage where the problem occurs. I could see that you are inserting a FacetWP shortcode inside an Elementor element. Please see the attached screenshot. We might be facing a compatibility issue here, either with FacetWP or with Elementor. We would like to ask your help in replicating this issue. I created a test site and installed and configured WPML with ACF and Elementor. You can access this site admin directly by pressing this link.
hidden link
I created a very simple field group with one checkbox field. You can see it here.
hidden link
Can you please install FacetWP on the test site and help us replicate this issue?
I have just installed the following plugins: FacetWP, FacetWP Multilanguage Support, and FacetWP Elementor.
I believe that the issue we are experiencing on our site is also present on the testing site you provided (please refer to the "Yes and No Post" -> hidden link).
In English, the values in the array are "yes" and "no" (which is correct, see english_post.png). However, when I switch the language to French, the post title and text are correctly translated, but the ACF field is not translated correctly (see french_post.png). It should display "FR yes" and "FR no" as translated via the String Translation menu. Please see the attached screenshot for reference (see string_translation_wpml.png).
Could you please confirm if I have understood the issue correctly? Or, if there is anything else that I should consider?
It was not working because of certain settings. When I try it as it should be, it is working. Please see this page.
hidden link
I've come to this conclusion after discussing this issue with my team.
I'm sorry if I was not clear enough in my previous reply. I'm referring to the following I wrote:
But in your case, other plugins are involved. I checked your staging site and edited the homepage where the problem occurs. I could see that you are inserting a FacetWP shortcode inside an Elementor element.
What I want to ask you is the following. Please try to replicate the issue as things are configured on your site. Indeed Elementor and FacetWP are active. But you didn't insert the FacetWP shortcode in an Elementor Shortcode element like it was done on your site.
Can you please try to proceed like that and see if the issue can be replicated?
Thank you for your assistance! I followed your advice and placed the FacetWP shortcode within an Elementor Shortcode element. The result is that the FacetWP checkboxes are now being rendered correctly on the English version of the site, as you can see here: hidden link.
However, I encountered an issue with the French version of the site, as the FacetWP checkboxes are not being rendered correctly. You can see the issue here: hidden link.
Nevertheless, the listed posts on the French and English version display the correct labels.
I would appreciate any further suggestions you might have for resolving this issue. Thank you again for your assistance.
Hi, and thank you for replicating the issue on the sandbox site.
After pressing the Re-index button in Settings -> FacetWP, the checkboxes are rendered correctly on the French page. However, the translations still do not show.
I'm consulting our second-tier supporters regarding this issue. When I have their reply, I will update you here.
Our compatibility developer has found a workaround for this issue. Here is what you need to do.
1. Take a backup of your site in case something goes wrong.
2. Add the following function to the functions.php file of your theme and save the changes.
// WPML Workaround for compsupp-6751
function wpml_compsupp6751_translate_facet_display_value( $label, $args ) {
if ( class_exists('Sitepress') ) {
$wpml_default_lang = apply_filters('wpml_default_language', NULL );
$wpml_current_lang = apply_filters( 'wpml_current_language', NULL );
if ($wpml_default_lang == $wpml_current_lang ) {
do_action( 'wpml_register_single_string', 'FacetWP', 'Facet Display Value : '.substr($label, 0, 10), $label );
}
// Apply the translation to the string
$label = apply_filters('wpml_translate_single_string', $label , 'FacetWP', 'Facet Display Value : '.substr($label, 0, 10) );
}
return $label;
}
add_filter( 'facetwp_facet_display_value', 'wpml_compsupp6751_translate_facet_display_value', 10, 2 );
3. On the front end, visit the page with the ACF fields in the original language. This will register the strings into Strings Translation.
4. Go to WPML -> Strings Translation and filter to show the FacetWP domain. Under it, you will find the strings with the name "Facet Display Value : *name". Those will be the label of the checkbox strings. Translate them into the other language. Please see the attached screenshot.
**** Important! Please make a full site backup (files and DB) before you proceed with those steps****
Now the problem on the translated page/post should be solved. You should see the translated checkbox field labels.
Please note that this is only a workaround we can provide for now as a temporary fix. Our compatibility team will also contact the FacetWP developers to work with them to fix this issue permanently. Please be aware that the permanent fix release also depends on the cooperation of FacetWP.
Can you please inform me if this workaround works for you?
thank you and also thanks to your compatibility developer for providing a solution! I am currently trying to check whether it also works on the staging site.
I am facing the following issue: the default language is German but the German strings are registered in English (see screenshot below). Is there a way to register them in German?