Skip Navigation

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.

Tagged: 

This topic contains 17 replies, has 2 voices.

Last updated by marcoP-123 1 year, 6 months ago.

Assisted by: Itamar.

Author Posts
May 9, 2023 at 9:39 am #13611977

marcoP-123

I'm not certain if this falls under the scope of this support ticket, but we have an additional query about translating ACF fields within the code using WPML.

We encountered some difficulties with ACF in the theme code, but we managed to find a workaround. However, it's not the most optimal solution. We noticed that when we used the_field('fieldname'), WPML consistently displayed the original language instead of the current language.

May 9, 2023 at 9:44 am #13611989

marcoP-123

I've noticed that when I translate the options, the default language options disappear. So it should not be a problem!

Thank you so much for your support and the solution you provided. We plan to translate the filters and mark this issue as resolved once we are done with translating. However, we'll keep an eye out for any difficulties that may arise during the translation process.

May 9, 2023 at 9:54 am #13612163

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+02:00)

Hi,

I'm glad that the workaround fixed the issue on your site.

Since my last reply, you added three replies, and I'm unsure whether or not you still need help with anything. In any case, for the other issues, like your question about the_field, please open a new ticket n our support forum, as it is a different issue.

I'll wait to hear whether you need further help with the FacetWP issue.

Regards,
Itamar.

May 9, 2023 at 9:58 am #13612221

marcoP-123

Please excuse the confusion. Right now we don't need any further assistance and everything seems to work as it should. We will mark the issue as resolved once we are done with translating the filters.

Thank you again, really.