You can add this in your main master page layout.
<script runat="server"> protected void Page_Load(object sender, EventArgs e) { if (CurrentDocument != null) { CMS.UIControls.ContentPage page= this.Page as CMS.UIControls.ContentPage; if (page != null) { string lang= CMS.Localization.LocalizationContext.CurrentCulture.CultureCode; page.XmlNamespace += " lang=\"" + lang + "\""; } } } </script>
Brenden's answer is spot on. I will also add this line because sometime some of the tools give this error unless this tag is defined too.
page.XmlNamespace += " xml:lang=\"" + lang + "\"";
Thanks Brenden and chetan for the answer.
Hi Everyone,
I've used the code above In my master page layout. It's rendering the lang attributes perfectly when I inspect the page, but when I run it through a validator, and on view page source, I'm getting a duplication of lang="en-CA". Any thoughts?
Not sure where the problem is I added this code and it is giving the error:
Uncaught SyntaxError: Unexpected token void
at the line: "protected void Page_Load(object sender, EventArgs e)"
Any ideas?
Please, sign in to be able to submit a new answer.