• Resolved mdpca

    (@mdpca)


    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 3 years, 10 months ago by mdpca.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter mdpca

    (@mdpca)

    Correction –

    NOTE: The <span> tag that appears contains .select2-selection__rendered as a class. This class IS on the page when it loads. It appears after > only when selecting a “Vehicle Make”. Before that, has display:non to not show the field.
    **When adding the data-no-translation attribute to the always present span tag manually through browser inspect, its works. But when using either your code snippet or entering this into the “Exclude selectors from translation” section… it never appears?

    Why is the att not showing when targeting using either or above methods? I tried with other .class and #id and it works. But not for this specific class…im out of ideas besides hard coding it in which is not an option for me right now.

    Thread Starter mdpca

    (@mdpca)

    Solved. Hardcoded the attribute – data-no-translation. Was a DOM element – that is being created/exists – only when instructed to appear on page. Found the responsible .js file…searched for class and added attribute.

    • This reply was modified 3 years, 10 months ago by mdpca.
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘data-no-translation attribute not working’ is closed to new replies.