Skip Navigation

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

Problem:
You are working on a site under development and have added a plugin in the widgets. While you can translate some strings using WPML, others remain untranslated.
Solution:
First, ensure you back up your site. Then, add the following code to your

// WPMl Workaround for compsupp-7428
function wpml_compsupp7428_register_and_translate_labels_for_wooVPF($label) {
 
    if (class_exists('Sitepress')) {
        $string = $label;
        $textdomain = ' woo_vpf_ymm'; // Replace with your actual text domain
        $string_name = 'Woo VFP: ' . substr($string, 0, 20);
 
        if (apply_filters('wpml_default_language', NULL) == apply_filters('wpml_current_language', NULL)) {
            do_action('wpml_register_single_string', $textdomain, $string_name, $string);
        }
 
        // Apply the translation to the string
        $label = apply_filters('wpml_translate_single_string', $string, $textdomain, $string_name);
    }
 
    return $label;
}
 
// List of filters to apply the custom function
$label_filters = [
    'woo_vpf_ymm_year_label',
    'woo_vpf_ymm_make_label',
    'woo_vpf_ymm_model_label',
    'woo_vpf_ymm_engine_label',
    'woo_vpf_ymm_category_label',
    'woo_vpf_ymm_keyword_label',
    'widget_woo_vpf_ymm_label_year',
    'widget_woo_vpf_ymm_label_make',
    'widget_woo_vpf_ymm_label_model',
    'widget_woo_vpf_ymm_label_engine',
    'widget_woo_vpf_ymm_label_category',
    'widget_woo_vpf_ymm_label_keyword',
    'widget_woo_vpf_ymm_label_search',
    'widget_woo_vpf_ymm_label_reset_search'
];
 
// Apply the custom function to each filter
foreach ($label_filters as $filter) {
    add_filter($filter, 'wpml_compsupp7428_register_and_translate_labels_for_wooVPF');
}

After adding the code, follow these steps:

  • Go to the page with the strings in the original language to register it.
  • Navigate to WPML > String Translator and locate the strings.
  • Change the language of the strings from English to French.
  • Translate the strings to English.

If this solution does not resolve your issue or seems outdated, we recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If further assistance is needed, please open a new support ticket at WPML support forum.

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.

This topic contains 4 replies, has 2 voices.

Last updated by Ilyes 3 months ago.

Assisted by: Ilyes.

Author Posts
June 18, 2024 at 2:05 pm

jerisscloudcenter

Background of the issue:
I am working on a site under development. I've added a plugin in the widgets, and I'm trying to translate its strings using WPML.

Symptoms:
Some strings in the plugin could be translated, but some could not.

Questions:
Why can't I translate some strings in the plugin?

June 18, 2024 at 2:44 pm
June 18, 2024 at 3:47 pm #15750021

Ilyes
Supporter

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

Timezone: Pacific/Easter (GMT-05:00)

Hello,

In order to see if this issue is happening because of the configuration of your site, or just the combination of WooCommerce Vehicle Parts Finder & WPML we need to isolate the issue.

I’ve created a sandbox here: hidden link

I’ve already configured WPML in 2 languages.

Please do the following:

- Open the Sandbox link mentioned above
- Download and activate the WooCommerce Vehicle Parts Finder plugin you are using.
- Create a similar widget using the labels you've set under WooCommerce settings.
- Translate the widget using String Translation and save the changes.

Does the issue replicate?

Please note that we only need the theme/plugin and the related functionality, you don’t need to set up an entire website or clone your existing site.
https://wpml.org/faq/how-to-reproduce-issues-and-share-them-with-wpml-support/

Let me know when it is done.
Best regards,

June 19, 2024 at 6:11 pm #15757930

jerisscloudcenter

Hi Ilyes,

I reproduced the issue on your sandbox with minimal installation and with a default theme (storefront). You can visit the home page in English / French.

FRENCH : hidden link
ENGLISH : hidden link

Then check the widgets with the original string being in French (and the translation being in English). In WPML String Translation, I found the strings and I translated them from French to English, but they don't appear all appear translated in the English page.

Only 1 string "Brand" seems to appear with the proper translation between French & English, but not the others. Please check why.

3.png
2.png
1.png
June 20, 2024 at 5:53 pm #15765907

Ilyes
Supporter

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

Timezone: Pacific/Easter (GMT-05:00)

Hello,

Thanks for taking the time to replicate this,

I have sent this to our compatibility team, I will let you know once I get an update,

Best,

June 25, 2024 at 4:35 pm #15823088

Ilyes
Supporter

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

Timezone: Pacific/Easter (GMT-05:00)

Hello,

Thank you for your patience,

We were able to find a workaround, and the strings are now translated under the sandbox : hidden link

Workaround

Take a backup of your site, and then add the following code to the functions.php file:

// WPMl Workaround for compsupp-7428
function wpml_compsupp7428_register_and_translate_labels_for_wooVPF($label) {

    if (class_exists('Sitepress')) {
        $string = $label;
        $textdomain = '	woo_vpf_ymm'; // Replace with your actual text domain
        $string_name = 'Woo VFP: ' . substr($string, 0, 20);

        if (apply_filters('wpml_default_language', NULL) == apply_filters('wpml_current_language', NULL)) {
            do_action('wpml_register_single_string', $textdomain, $string_name, $string);
        }

        // Apply the translation to the string
        $label = apply_filters('wpml_translate_single_string', $string, $textdomain, $string_name);
    }

    return $label;
}

// List of filters to apply the custom function
$label_filters = [
    'woo_vpf_ymm_year_label',
    'woo_vpf_ymm_make_label',
    'woo_vpf_ymm_model_label',
    'woo_vpf_ymm_engine_label',
    'woo_vpf_ymm_category_label',
    'woo_vpf_ymm_keyword_label',
    'widget_woo_vpf_ymm_label_year',
    'widget_woo_vpf_ymm_label_make',
    'widget_woo_vpf_ymm_label_model',
    'widget_woo_vpf_ymm_label_engine',
    'widget_woo_vpf_ymm_label_category',
    'widget_woo_vpf_ymm_label_keyword',
    'widget_woo_vpf_ymm_label_search',
    'widget_woo_vpf_ymm_label_reset_search'
];

// Apply the custom function to each filter
foreach ($label_filters as $filter) {
    add_filter($filter, 'wpml_compsupp7428_register_and_translate_labels_for_wooVPF');
}
    Go to the page with the strings in original language, to register it
    Go to WPML > String Translator and find the strings
    Change the language of the strings from english to french
    Translate the strings to english

Please let me know if you need help with this,

Best,

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.