static Locale detectLanguage(XmlPullParser xpp) {
        // Default language is English ("en").
        Locale language = Locale.forLanguageTag("en");
        for (int i = 0; i < xpp.getAttributeCount(); i++) {
            if ("lang".equals(xpp.getAttributeName(i))) {
                language = Locale.forLanguageTag(xpp.getAttributeValue(i));
            }
        }
        return language;
    }
Parses a locale from the 'lang' attribute of the element that the provided parser is currently on.

This method returns the English locale when there is no 'lang' attribute found. It will return an undefined
Locale if the value of the 'lang' attribute could not be used to identify a language.

@param xpp An XML parser
@return A Locale
xmppserver/src/main/java/org/jivesoftware/openfire/session/Session.java