ker/cls/WTag.js
function(id) {
            if (!$$.App) $$.App = this;
            if (!$$.App._languages) {
                // Initialise localization.
                var languages = [],
                langStyle = document.createElement("style"),
                children = document.querySelectorAll("[lang]");
                document.head.appendChild(langStyle);
                $$.App._langStyle = langStyle;
                for (var i = 0 ; i < children.length ; i++) {
                    var child = children[i];
                    lang = child.getAttribute("lang");
                    found = false;
                    for (k = 0 ; k < languages.length ; k++) {
                        if (languages[k] == lang) {
                            found = true;
                            break;
                        }
                    }
                    if (!found) {
                        languages.push(lang);
                    }
                }
                $$.App._languages = languages;
            }

            var that = this, lang, k, found, first, txt;
            languages = $$.App._languages;
            if (id === undefined) {
                // Return current language.
                lang = $$.lang();  // localStorage.getItem("wtag-language");
                if (!lang) {
                    lang = navigator.language || navigator.browserLanguage || "fr";
                    lang = lang.substr(0, 2);
                }
                $$.lang(lang);
                // localStorage.setItem("wtag-language", lang);
                return lang;
            } else {
                // Set current language and display localized elements.
                found = false;
                for (k = 0 ; k < languages.length ; k++) {
                    if (languages[k] == id) {
                        found = true;
                        break;
                    }
                }
                if (!found) {
                    id = languages[0];
                }
                txt = "";
                first = true;
                for (k = 0 ; k < languages.length ; k++) {
                    lang = languages[k];
                    if (lang != id) {
                        if (first) {
                            first = false;
                        } else {
                            txt += ",";
                        }
                        txt += "[lang=" + lang + "]";
                    }
                }
                $$.App._langStyle.textContent = txt + "{display: none}";
                $$.lang(id);
                //localStorage.setItem("wtag-language", id);
            }
        }
function(id) {
            if (!$$.App) $$.App = this;
            if (!$$.App._languages) {
                // Initialise localization.
                var languages = [],
                langStyle = document.createElement("style"),
                children = document.querySelectorAll("[lang]");
                document.head.appendChild(langStyle);
                $$.App._langStyle = langStyle;
                for (var i = 0 ; i < children.length ; i++) {
                    var child = children[i];
                    lang = child.getAttribute("lang");
                    found = false;
                    for (k = 0 ; k < languages.length ; k++) {
                        if (languages[k] == lang) {
                            found = true;
                            break;
                        }
                    }
                    if (!found) {
                        languages.push(lang);
                    }
                }
                $$.App._languages = languages;
            }

            var that = this, lang, k, found, first, txt;
            languages = $$.App._languages;
            if (id === undefined) {
                // Return current language.
                lang = $$.lang();  // localStorage.getItem("wtag-language");
                if (!lang) {
                    lang = navigator.language || navigator.browserLanguage || "fr";
                    lang = lang.substr(0, 2);
                }
                $$.lang(lang);
                // localStorage.setItem("wtag-language", lang);
                return lang;
            } else {
                // Set current language and display localized elements.
                found = false;
                for (k = 0 ; k < languages.length ; k++) {
                    if (languages[k] == id) {
                        found = true;
                        break;
                    }
                }
                if (!found) {
                    id = languages[0];
                }
                txt = "";
                first = true;
                for (k = 0 ; k < languages.length ; k++) {
                    lang = languages[k];
                    if (lang != id) {
                        if (first) {
                            first = false;
                        } else {
                            txt += ",";
                        }
                        txt += "[lang=" + lang + "]";
                    }
                }
                $$.App._langStyle.textContent = txt + "{display: none}";
                $$.lang(id);
                //localStorage.setItem("wtag-language", id);
            }
        }
function ( id ) { if ( ! $$ . App ) $$ . App = this ; if ( ! $$ . App . _languages ) { // Initialise localization. var languages = [ ] , langStyle = document . createElement ( "style" ) , children = document . querySelectorAll ( "[lang]" ) ; document . head . appendChild ( langStyle ) ; $$ . App . _langStyle = langStyle ; for ( var i = 0 ; i < children . length ; i ++ ) { var child = children [ i ] ; lang = child . getAttribute ( "lang" ) ; found = false ; for ( k = 0 ; k < languages . length ; k ++ ) { if ( languages [ k ] == lang ) { found = true ; break ; } } if ( ! found ) { languages . push ( lang ) ; } } $$ . App . _languages = languages ; } var that = this , lang , k , found , first , txt ; languages = $$ . App . _languages ; if ( id === undefined ) { // Return current language. lang = $$ . lang ( ) ; // localStorage.getItem("wtag-language"); if ( ! lang ) { lang = navigator . language || navigator . browserLanguage || "fr" ; lang = lang . substr ( 0 , 2 ) ; } $$ . lang ( lang ) ; // localStorage.setItem("wtag-language", lang); return lang ; } else { // Set current language and display localized elements. found = false ; for ( k = 0 ; k < languages . length ; k ++ ) { if ( languages [ k ] == id ) { found = true ; break ; } } if ( ! found ) { id = languages [ 0 ] ; } txt = "" ; first = true ; for ( k = 0 ; k < languages . length ; k ++ ) { lang = languages [ k ] ; if ( lang != id ) { if ( first ) { first = false ; } else { txt += "," ; } txt += "[lang=" + lang + "]" ; } } $$ . App . _langStyle . textContent = txt + "{display: none}" ; $$ . lang ( id ) ; //localStorage.setItem("wtag-language", id); } }
Return or set the current language.
@memberof WTag
Return or set the current language .