data-no-translation attribute not working | WordPress.org

Hi,

I am using the snippet in your documentation to add the attribute data-no-translation to specific id and class.

add_filter( 'trp_no_translate_selectors', 'GMtrpc_no_stranslate_selectors', 10, 2);
function GMtrpc_no_stranslate_selectors($selectors_array, $language){

    $selectors_array[] = '.select2-results__options'; // no, does not add the attribute
    $selectors_array[] = '#gm_qr_make'; // yes, attribute added

    return $selectors_array;
}

It works well for when using the id but not being added when using the class.
**all “Vehicle makes” are being pulled from an API using PHP. Then some jQuery to display.

Note: This is a weird issue I am having and have spent lots of time trying to figure it out. This is a drop down that customers select Year > Make > Model > Engine. jQeury hides the next dropdown until an option is selected from the previous. No issues.

However, depending the Year selected > will determine the Vehicle Makes that will be shown …for some reason Dodge and Ford are not staying the in original English language and are always displaying in French. They show in English correctly, but are not supposed to translate into French when using fr_ca as language of choice. This goes for the make and the model and the trim.

NOTE: The <span> tag that appears contains .select2-selection__rendered as a class. This class in not on the page when it loads. It appears after > only when selecting a “Vehicle Make”.
**When adding the data-no-translation attribute to the newly present span tag manually through browser inspect, its works. but will no longer be there after a new make is selected. I need it to there always ..I cannot hard code it…cannot find the files to do so. And also, why always those 2 and not the others right?

Please help, Thank you

  • This topic was modified 9 hours ago by mdpca.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Your Advertisement Here