languages templates Developer Jahia 7.3 Jahia 8

Adding lang tag in template

Question

How could I add the lang attribute in my HTML tag?  I want to add the language of the text in an attribute based on the current language                                                                            

<html xmlns="http://www.w3.org/1999/xhtml" lang="en">

 

Answer

The lang attribute specifies the language of the element's content.
To use the current language of your site, simply do this in your template:

<c:set var="language" value="${renderContext.mainResourceLocale.language}"/>
<html xmlns="http://www.w3.org/1999/xhtml" lang="${language}">