function parseProperties(text) {
      var dictionary = [];

      // token expressions
      var reBlank = /^\s*|\s*$/;
      var reComment = /^\s*#|^\s*$/;
      var reSection = /^\s*\[(.*)\]\s*$/;
      var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
      var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
      var reUnicode = /\\u([0-9a-fA-F]{1,4})/g;
      var reMultiline = /[^\\]\\$/;

      // parse the *.properties file into an associative array
      function parseRawLines(rawText, extendedSyntax) {
        var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
        var currentLang = '*';
        var genericLang = lang.replace(/-[a-z]+$/i, '');
        var skipLang = false;
        var match = '';

        for (var i = 0; i < entries.length; i++) {
          var line = entries[i];

          // comment or blank line?
          if (reComment.test(line)) {
            continue;
          }

          // multi-line?
          while (reMultiline.test(line) && i < entries.length) {
            line = line.slice(0, line.length - 1) +
              entries[++i].replace(reBlank, '');
          }

          // the extended syntax supports [lang] sections and @import rules
          if (extendedSyntax) {
            if (reSection.test(line)) { // section start?
              match = reSection.exec(line);
              currentLang = match[1];
              skipLang = (currentLang !== '*') &&
                  (currentLang !== lang) && (currentLang !== genericLang);
              continue;
            } else if (skipLang) {
              continue;
            }
            if (reImport.test(line)) { // @import rule?
              match = reImport.exec(line);
              loadImport(baseURL + match[1]); // load the resource synchronously
            }
          }

          // key-value pair
          var tmp = line.match(reSplit);
          if (tmp && tmp.length == 3) {
            // unescape unicode char codes if needed (e.g. '\u00a0')
            var val = tmp[2].replace(reUnicode, function(match, token) {
              return unescape('%u' + '0000'.slice(token.length) + token);
            });
            dictionary[tmp[1]] = evalString(val);
          }
        }
      }

      // import another *.properties file
      function loadImport(url) {
        loadResource(url, function(content) {
          parseRawLines(content, false); // don't allow recursive imports
        }, null, false); // load synchronously
      }

      // fill the dictionary
      parseRawLines(text, true);
      return dictionary;
    }
// parse *.properties text data into an l10n dictionary
parse *.properties text data into an l10n dictionary
parse * . properties text data into an l10n dictionary
function parseProperties(text) {
      var dictionary = [];
      var reBlank = /^\s*|\s*$/;
      var reComment = /^\s*#|^\s*$/;
      var reSection = /^\s*\[(.*)\]\s*$/;
      var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
      var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
      var reUnicode = /\\u([0-9a-fA-F]{1,4})/g;
      var reMultiline = /[^\\]\\$/;
      function parseRawLines(rawText, extendedSyntax) {
        var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
        var currentLang = '*';
        var genericLang = lang.replace(/-[a-z]+$/i, '');
        var skipLang = false;
        var match = '';
        for (var i = 0; i < entries.length; i++) {
          var line = entries[i];
          if (reComment.test(line)) {
            continue;
          }
          while (reMultiline.test(line) && i < entries.length) {
            line = line.slice(0, line.length - 1) +
              entries[++i].replace(reBlank, '');
          }
          if (extendedSyntax) {
            if (reSection.test(line)) { 
              match = reSection.exec(line);
              currentLang = match[1];
              skipLang = (currentLang !== '*') &&
                  (currentLang !== lang) && (currentLang !== genericLang);
              continue;
            } else if (skipLang) {
              continue;
            }
            if (reImport.test(line)) { 
              match = reImport.exec(line);
              loadImport(baseURL + match[1]); 
            }
          }
          var tmp = line.match(reSplit);
          if (tmp && tmp.length == 3) {
            var val = tmp[2].replace(reUnicode, function(match, token) {
              return unescape('%u' + '0000'.slice(token.length) + token);
            });
            dictionary[tmp[1]] = evalString(val);
          }
        }
      }
      function loadImport(url) {
        loadResource(url, function(content) {
          parseRawLines(content, false); 
        }, null, false); 
      }
      parseRawLines(text, true);
      return dictionary;
    }
function parseProperties ( text ) { var dictionary = [ ] ; var reBlank = / ^\s*|\s*$ / ; var reComment = / ^\s*#|^\s*$ / ; var reSection = / ^\s*\[(.*)\]\s*$ / ; var reImport = / ^\s*@import\s+url\((.*)\)\s*$ / i ; var reSplit = / ^([^=\s]*)\s*=\s*(.+)$ / ; var reUnicode = / \\u([0-9a-fA-F]{1,4}) / g ; var reMultiline = / [^\\]\\$ / ; function parseRawLines ( rawText , extendedSyntax ) { var entries = rawText . replace ( reBlank , '' ) . split ( / [\r\n]+ / ) ; var currentLang = '*' ; var genericLang = lang . replace ( / -[a-z]+$ / i , '' ) ; var skipLang = false ; var match = '' ; for ( var i = 0 ; i < entries . length ; i ++ ) { var line = entries [ i ] ; if ( reComment . test ( line ) ) { continue ; } while ( reMultiline . test ( line ) && i < entries . length ) { line = line . slice ( 0 , line . length - 1 ) + entries [ ++ i ] . replace ( reBlank , '' ) ; } if ( extendedSyntax ) { if ( reSection . test ( line ) ) { match = reSection . exec ( line ) ; currentLang = match [ 1 ] ; skipLang = ( currentLang !== '*' ) && ( currentLang !== lang ) && ( currentLang !== genericLang ) ; continue ; } else if ( skipLang ) { continue ; } if ( reImport . test ( line ) ) { match = reImport . exec ( line ) ; loadImport ( baseURL + match [ 1 ] ) ; } } var tmp = line . match ( reSplit ) ; if ( tmp && tmp . length == 3 ) { var val = tmp [ 2 ] . replace ( reUnicode , function ( match , token ) { return unescape ( '%u' + '0000' . slice ( token . length ) + token ) ; } ) ; dictionary [ tmp [ 1 ] ] = evalString ( val ) ; } } } function loadImport ( url ) { loadResource ( url , function ( content ) { parseRawLines ( content , false ) ; } , null , false ) ; } parseRawLines ( text , true ) ; return dictionary ; }
parse *.properties text data into an l10n dictionary
parse * . properties text data into an l10n dictionary
// token expressions // parse the *.properties file into an associative array // comment or blank line? // multi-line? // the extended syntax supports [lang] sections and @import rules // section start? // @import rule? // load the resource synchronously // key-value pair // unescape unicode char codes if needed (e.g. '\u00a0') // import another *.properties file // don't allow recursive imports // load synchronously // fill the dictionary