Explore the community Forums Lectora Lectora Questions & Answers How to set browser language?

Tagged: 

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #345355 Score: 0
    Profile photo of JWheat
    JWheat
    Member
    beginner
    intermediate
    @JWheat

    Hello,

    I’m building a bilingual course that includes text entry fields.  The course is English and French.  In the French pages, I would like to set the html lang tag = “fr” … I.e. <span class=”na”>lang</span><span class=”o”>=</span><span class=”s”>”fr”.</span>

    Setting the fr language will allow the autocorrect for text entry to adjust to French.

     

    I’ve attempted this in both “header scripting” and “top of file scripting” … and it generates but it still generates a lang = “en” below it.

     

    <span style=”color: #0000ff; font-size: small;”><</span><span style=”color: #a31515; font-size: small;”>html</span> <span style=”color: #ff0000; font-size: small;”>lang</span><span style=”color: #0000ff; font-size: small;”>=”fr”></span>

    <span style=”color: #0000ff; font-size: small;”><!</span><span style=”color: #a31515; font-size: small;”>DOCTYPE</span> <span style=”color: #ff0000; font-size: small;”>html</span><span style=”color: #0000ff; font-size: small;”>></span>

    <span style=”color: #0000ff; font-size: small;”><</span><span style=”color: #a31515; font-size: small;”>html</span> <span style=”color: #ff0000; font-size: small;”>lang</span><span style=”color: #0000ff; font-size: small;”>=”en”></span>

    <!–GENERATED BY: Lectora Publisher v.12.1.4(10190) (http://www.trivantis.com) –>

     

    Has anyone run across anything similar?  Editing the final HTML is not a desirable option.

     

    Thank you

     

    #345365 Score: 2
    Profile photo of Darrel Somoza
    Darrel Somoza
    Member
    contributor
    friend finder
    beginner
    intermediate
    junior moderator
    advanced
    wise owl
    curious george
    profile
    169 pts
    @Klaatu

    Add an html extension header scripting with the following:

    document.getElementsByTagName(“html”)[0].removeAttribute(“lang”);
    document.getElementsByTagName(“html”)[0].setAttribute(“lang”, “fr”);

    If you prefer jQuery, add the library in a header scripting extension and then add another header scripting after it with:

    $(“html”).removeAttr(“lang”);
    $(“html”).attr(“lang”,”fr”);

     

    This post has received 2 votes up.
    #345367 Score: 0
    Profile photo of Darrel Somoza
    Darrel Somoza
    Member
    contributor
    friend finder
    beginner
    intermediate
    junior moderator
    advanced
    wise owl
    curious george
    profile
    169 pts
    @Klaatu

    Oh, I forgot to mention that if you cut and paste from the forum you will need to replace all the quotes as they do not copy over correctly.

    #345369 Score: 0
    Profile photo of JWheat
    JWheat
    Member
    beginner
    intermediate
    @JWheat

    Thank you … that worked like a charm and set the correct attribute.

    Now it depends on the user’s browser add-in setting for spelling correction (at least on Windows).

     

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.