How to set browser language?

jwheat
jwheat Community Member Posts: 8
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

 

Comments

  • klaatu
    klaatu Community Member Posts: 988
    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");

     
  • klaatu
    klaatu Community Member Posts: 988
    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.
  • jwheat
    jwheat Community Member Posts: 8
    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).

     
Sign In or Register to comment.

So You Wanna Be An eLearning ROCKSTAR?

We're all fans of eLearning here! Want to become an eLearning ROCKSTAR? Just click on one of the buttons below to start your rocking journey!