server.js
function matchLocale(locale) {
    var found = false;
    if (!locale) return false;
    locale = locale.replace(/_/g, '-').toLowerCase();
    if (localesLookup[locale]) return localesLookup[locale];
    if (options.matchSubTags) {
      while (~locale.indexOf('-')) {
        var index = locale.lastIndexOf('-');
        locale = locale.substring(0, index);
        if (localesLookup[locale]) {
          found = localesLookup[locale];
          break;
        }
      }
    }
    return found;
  }
function matchLocale(locale) {
    var found = false;
    if (!locale) return false;
    locale = locale.replace(/_/g, '-').toLowerCase();
    if (localesLookup[locale]) return localesLookup[locale];
    if (options.matchSubTags) {
      while (~locale.indexOf('-')) {
        var index = locale.lastIndexOf('-');
        locale = locale.substring(0, index);
        if (localesLookup[locale]) {
          found = localesLookup[locale];
          break;
        }
      }
    }
    return found;
  }
function matchLocale ( locale ) { var found = false ; if ( ! locale ) return false ; locale = locale . replace ( / _ / g , '-' ) . toLowerCase ( ) ; if ( localesLookup [ locale ] ) return localesLookup [ locale ] ; if ( options . matchSubTags ) { while ( ~ locale . indexOf ( '-' ) ) { var index = locale . lastIndexOf ( '-' ) ; locale = locale . substring ( 0 , index ) ; if ( localesLookup [ locale ] ) { found = localesLookup [ locale ] ; break ; } } } return found ; }
helper function to detect locale or sublocale
helper function to detect locale or sublocale