core/i18n.js
function guessLanguage(request){
	//console.log("guessLanguage");
    if(typeof request === 'object'){
        var language_header = request.headers['accept-language'],
        languages = [];
        regions = [];
        request.languages = [currentLocale];
		/*
		for (x in request.languages)
		{
			console.log(request.languages[x] + x);
		}
		*/
        request.regions = [currentLocale];
        request.language = currentLocale;
        request.region = currentLocale;

        if (language_header) {
            language_header.split(',').forEach(function(l) {
                header = l.split(';', 1)[0];
                lr = header.split('-', 2);
                if (lr[0]) {
                    languages.push(lr[0].toLowerCase());
                }
                if (lr[1]) {
                    regions.push(lr[1].toLowerCase());
                }
            });

            if (languages.length > 0) {
                request.languages = languages;
                request.language = languages[0];
            }

            if (regions.length > 0) {
                request.regions = regions;
                request.region = regions[0];
            }
        }
        i18n.setLocale(request.language);
    }
}
function guessLanguage(request){
	//console.log("guessLanguage");
    if(typeof request === 'object'){
        var language_header = request.headers['accept-language'],
        languages = [];
        regions = [];
        request.languages = [currentLocale];
		/*
		for (x in request.languages)
		{
			console.log(request.languages[x] + x);
		}
		*/
        request.regions = [currentLocale];
        request.language = currentLocale;
        request.region = currentLocale;

        if (language_header) {
            language_header.split(',').forEach(function(l) {
                header = l.split(';', 1)[0];
                lr = header.split('-', 2);
                if (lr[0]) {
                    languages.push(lr[0].toLowerCase());
                }
                if (lr[1]) {
                    regions.push(lr[1].toLowerCase());
                }
            });

            if (languages.length > 0) {
                request.languages = languages;
                request.language = languages[0];
            }

            if (regions.length > 0) {
                request.regions = regions;
                request.region = regions[0];
            }
        }
        i18n.setLocale(request.language);
    }
}
function guessLanguage ( request ) { //console.log("guessLanguage"); if ( typeof request === 'object' ) { var language_header = request . headers [ 'accept-language' ] , languages = [ ] ; regions = [ ] ; request . languages = [ currentLocale ] ; /*
		for (x in request.languages)
		{
			console.log(request.languages[x] + x);
		}
		*/ request . regions = [ currentLocale ] ; request . language = currentLocale ; request . region = currentLocale ; if ( language_header ) { language_header . split ( ',' ) . forEach ( function ( l ) { header = l . split ( ';' , 1 ) [ 0 ] ; lr = header . split ( '-' , 2 ) ; if ( lr [ 0 ] ) { languages . push ( lr [ 0 ] . toLowerCase ( ) ) ; } if ( lr [ 1 ] ) { regions . push ( lr [ 1 ] . toLowerCase ( ) ) ; } } ) ; if ( languages . length > 0 ) { request . languages = languages ; request . language = languages [ 0 ] ; } if ( regions . length > 0 ) { request . regions = regions ; request . region = regions [ 0 ] ; } } i18n . setLocale ( request . language ) ; } }
guess language setting based on http headers
guess language setting based on http headers