function normalizePrefs(preferences) {
    const langs = ['en', 'pt', 'fr'];

    function normalizeLang(lang) {
        return lang.substring(0,2).toLowerCase();
    }

    // lang
    if (preferences.lang == 'auto') {
        const lang = (window.navigator.languages && window.navigator.languages[0])
            || window.navigator.browserLanguage
            || window.navigator.language;

        preferences.lang = normalizeLang(lang);
    } else {
        preferences.lang = normalizeLang(preferences.lang);
    }

    if (langs.indexOf(preferences.lang) === -1) {
        preferences.lang = 'en';
    }

    return preferences;
}
/**
 * Normalize preferences.
 *
 * @param      object  preferences  The preferences
 *
 * @return     object  The normalized preferences
 */
Normalize preferences.
@param      object  preferences  The preferences

@return     object  The normalized preferences
Normalize preferences . @param object preferences The preferences @return object The normalized preferences
function normalizePrefs(preferences) {
    const langs = ['en', 'pt', 'fr'];
    function normalizeLang(lang) {
        return lang.substring(0,2).toLowerCase();
    }
    if (preferences.lang == 'auto') {
        const lang = (window.navigator.languages && window.navigator.languages[0])
            || window.navigator.browserLanguage
            || window.navigator.language;
        preferences.lang = normalizeLang(lang);
    } else {
        preferences.lang = normalizeLang(preferences.lang);
    }
    if (langs.indexOf(preferences.lang) === -1) {
        preferences.lang = 'en';
    }
    return preferences;
}
function normalizePrefs ( preferences ) { const langs = [ 'en' , 'pt' , 'fr' ] ; function normalizeLang ( lang ) { return lang . substring ( 0 , 2 ) . toLowerCase ( ) ; } if ( preferences . lang == 'auto' ) { const lang = ( window . navigator . languages && window . navigator . languages [ 0 ] ) || window . navigator . browserLanguage || window . navigator . language ; preferences . lang = normalizeLang ( lang ) ; } else { preferences . lang = normalizeLang ( preferences . lang ) ; } if ( langs . indexOf ( preferences . lang ) === - 1 ) { preferences . lang = 'en' ; } return preferences ; }
Normalize preferences.
Normalize preferences .
// lang