Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
FacetWP filters not displaying translation correctly.
Solution:
Add the following code to the functions.php file:

// 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 );

Then, visit the page with the FacetWP filters in the default language.
Finally, go to WPML -> String Translation and search for strings containing "Facet Display Value: ".
After translating them, the FacetWP filters will display correctly in the secondary languages.

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.

Our next available supporter will start replying to tickets in about 6.64 hours from now. Thank you for your understanding.

This topic contains 6 replies, has 2 voices.

Last updated by pavelZ-3 1 year, 5 months ago.

Assisted by: Eran Helzer.

Author Posts
June 8, 2023 at 8:35 am #13791177

pavelZ-3

I did as you wrote, the translated colors are now displayed in the Admin panel.
I didn't mention what I need it for.
I use these colors in filters, via FacetWP. Apparently it's important 🙂

On the pages, these filters remained untranslated. Here are examples of one page in different languages:
hidden link
hidden link

June 8, 2023 at 9:06 am #13791429

Eran Helzer
Supporter

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

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

Yes I see.

I checked to see if FacetWP is officially compatible and it is, but for full compatibility you do need to install the FacetWP Multilingual add-on.

Please follow their documentation and verify that you have configured everything as they show:
hidden link

After, please update me on if this resolves you issue.

June 8, 2023 at 10:31 am #13792203

pavelZ-3

FacetWP Multilingual is already installed and configured as instructed.

June 8, 2023 at 12:48 pm #13793243

Eran Helzer
Supporter

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

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

Understood.

In that case it will be best if I take a look at your website myself. I see you already supplied credentials so I will be using them, if you allow me.

I will also need to know if I can:
- Change themes
- Activate/deactivate plugins
- Make changes to the configuration of your website

Please make sure you have a backup of your website before we proceed.

I will wait until you confirm you have a working backup and you confirm what changes I can make.

June 8, 2023 at 1:42 pm #13793587

pavelZ-3

Yes, I have a backup. You can do whatever you want 🙂

June 9, 2023 at 5:15 am #13796577

Eran Helzer
Supporter

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

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

I have a solution for your issue. It seems like this issue with FacetWP has already come up and our developers have a workaround.
I tested it on your site and it works.

The issue was that the translated labels of the ACF fields are not being used correctly on the frontend, so what we did was register the correct strings. Then it is simply using WPML -> String Translation to translate a new set of labels, which will show up on the frontend.

This is the code I added to the *functions.php* file that registers the correct strings for translation:

// 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 );

Then, after visiting the site for the first time in the default language the strings are registered.

And finally, all that is left is to translate the newly registered labels. For that simply look for strings containing "Facet Display Value: " in the WPML -> String Translation tab. I have added a screenshot to show you exactly how.

Please update me on if this does not resolve your issue or you have any further questions.