• Resolved tkwing009

    (@tkwing009)


    hi,

    I have to translate the search button aria-label from <aria-label=”Search”> to 3 languages, and The language of label name of the button should match with the page language.

    Here is the original code:
    <button type=”submit” class=”btn btn-primary” aria-label=”Search” value=”Search”><span class=”fooicon fooicon-search”></span></button>

    I have written the code as following but it didn’t work at all:

    var e = document.querySelector(“button.btn.btn-primary”);

    var theLanguage = $(‘html’).attr(‘lang’);
    // Diferent language
    if (theLanguage == “en-US”) {
    e.setAttribute(“title”, “Search”);
    e.setAttribute(“aria-label”, “Search”);

    } else if
    (theLanguage == “zh-hant”) {
    e.setAttribute(“title”, “搜尋”);
    e.setAttribute(“aria-label”, “搜尋”);

    } else {
    e.setAttribute(“title”, “搜寻”);
    e.setAttribute(“aria-label”, “搜寻”);
    }`

    Could anyone indicate me how to make it? thanks

    my website:
    https://islanddhc.org.hk/express/networkproviderlist-tc/

    • This topic was modified 2 years, 10 months ago by tkwing009.
    • This topic was modified 2 years, 10 months ago by tkwing009.

    The page I need help with: [log in to see the link]

  • The topic ‘how to change the aria-label to different languages’ is closed to new replies.