Search code examples
gwtlang

How can a GWT served html page have the lang attribute set?


As per GAR compliance, language has to be indicate with page.

Question 2.9. Is the content’s human language indicated in the markup?
E.g. for a page written in all one language, `<html lang="fr">`, or for a multi-lingual page,  `<div lang="fr">`.

A GWT application indicates its supported locales list in in its gwt.xml, and the html page with the locale requested by the client gets served. How can a GWT application have the lang attribute set in the html tag? Our application is UI widget based, and therefore we don't have a host html page, but directly add the widget to the RootPanel().


Solution

  • Try this:

     Document.get().getDocumentElement().setAttribute("lang",
         LocaleInfo.getCurrentLocale().getLocaleName());