jquery.i18n.properties.js
function parseData(data, settings) {

        var parsed = '';
        var lines = data.split(/\n/);
        var regPlaceHolder = /(\{\d+})/g;
        var regRepPlaceHolder = /\{(\d+)}/g;
        var unicodeRE = /(\\u.{4})/ig;
        for (var i=0,j=lines.length;i<j;i++) {
            var line = lines[i];

            line = line.trim();
            if (line.length > 0 && line.match("^#") != "#") { // skip comments
                var pair = line.split('=');
                if (pair.length > 0) {
                    /** Process key & value */
                    var name = decodeURI(pair[0]).trim();
                    var value = pair.length == 1 ? "" : pair[1];
                    // process multi-line values
                    while (value.search(/\\$/) != -1) {
                        value = value.substring(0, value.length - 1);
                        value += lines[++i].trimRight();
                    }
                    // Put values with embedded '='s back together
                    for (var s = 2; s < pair.length; s++) {
                        value += '=' + pair[s];
                    }
                    value = value.trim();

                    /** Mode: bundle keys in a map */
                    if (settings.mode == 'map' || settings.mode == 'both') {
                        // handle unicode chars possibly left out
                        var unicodeMatches = value.match(unicodeRE);
                        if (unicodeMatches) {
                            unicodeMatches.forEach(function (match) {
                                value = value.replace(match, unescapeUnicode(match));
                            });
                        }
                        // add to map
                        if (settings.namespace) {
                            $.i18n.map[settings.namespace][name] = value;
                        } else {
                            $.i18n.map[name] = value;
                        }
                    }

                    /** Mode: bundle keys as vars/functions */
                    if (settings.mode == 'vars' || settings.mode == 'both') {
                        value = value.replace(/"/g, '\\"'); // escape quotation mark (")

                        // make sure namespaced key exists (eg, 'some.key')
                        checkKeyNamespace(name);

                        // value with variable substitutions
                        if (regPlaceHolder.test(value)) {
                            var parts = value.split(regPlaceHolder);
                            // process function args
                            var first = true;
                            var fnArgs = '';
                            var usedArgs = [];
                            parts.forEach(function (part) {

                                if (regPlaceHolder.test(part) && (usedArgs.length === 0 || usedArgs.indexOf(part) == -1)) {
                                    if (!first) {
                                        fnArgs += ',';
                                    }
                                    fnArgs += part.replace(regRepPlaceHolder, 'v$1');
                                    usedArgs.push(part);
                                    first = false;
                                }
                            });
                            parsed += name + '=function(' + fnArgs + '){';
                            // process function body
                            var fnExpr = '"' + value.replace(regRepPlaceHolder, '"+v$1+"') + '"';
                            parsed += 'return ' + fnExpr + ';' + '};';
                            // simple value
                        } else {
                            parsed += name + '="' + value + '";';
                        }
                    } // END: Mode: bundle keys as vars/functions
                } // END: if(pair.length > 0)
            } // END: skip comments
        }
        eval(parsed);
        settings.filesLoaded += 1;
    }
function parseData(data, settings) {

        var parsed = '';
        var lines = data.split(/\n/);
        var regPlaceHolder = /(\{\d+})/g;
        var regRepPlaceHolder = /\{(\d+)}/g;
        var unicodeRE = /(\\u.{4})/ig;
        for (var i=0,j=lines.length;i<j;i++) {
            var line = lines[i];

            line = line.trim();
            if (line.length > 0 && line.match("^#") != "#") { // skip comments
                var pair = line.split('=');
                if (pair.length > 0) {
                    /** Process key & value */
                    var name = decodeURI(pair[0]).trim();
                    var value = pair.length == 1 ? "" : pair[1];
                    // process multi-line values
                    while (value.search(/\\$/) != -1) {
                        value = value.substring(0, value.length - 1);
                        value += lines[++i].trimRight();
                    }
                    // Put values with embedded '='s back together
                    for (var s = 2; s < pair.length; s++) {
                        value += '=' + pair[s];
                    }
                    value = value.trim();

                    /** Mode: bundle keys in a map */
                    if (settings.mode == 'map' || settings.mode == 'both') {
                        // handle unicode chars possibly left out
                        var unicodeMatches = value.match(unicodeRE);
                        if (unicodeMatches) {
                            unicodeMatches.forEach(function (match) {
                                value = value.replace(match, unescapeUnicode(match));
                            });
                        }
                        // add to map
                        if (settings.namespace) {
                            $.i18n.map[settings.namespace][name] = value;
                        } else {
                            $.i18n.map[name] = value;
                        }
                    }

                    /** Mode: bundle keys as vars/functions */
                    if (settings.mode == 'vars' || settings.mode == 'both') {
                        value = value.replace(/"/g, '\\"'); // escape quotation mark (")

                        // make sure namespaced key exists (eg, 'some.key')
                        checkKeyNamespace(name);

                        // value with variable substitutions
                        if (regPlaceHolder.test(value)) {
                            var parts = value.split(regPlaceHolder);
                            // process function args
                            var first = true;
                            var fnArgs = '';
                            var usedArgs = [];
                            parts.forEach(function (part) {

                                if (regPlaceHolder.test(part) && (usedArgs.length === 0 || usedArgs.indexOf(part) == -1)) {
                                    if (!first) {
                                        fnArgs += ',';
                                    }
                                    fnArgs += part.replace(regRepPlaceHolder, 'v$1');
                                    usedArgs.push(part);
                                    first = false;
                                }
                            });
                            parsed += name + '=function(' + fnArgs + '){';
                            // process function body
                            var fnExpr = '"' + value.replace(regRepPlaceHolder, '"+v$1+"') + '"';
                            parsed += 'return ' + fnExpr + ';' + '};';
                            // simple value
                        } else {
                            parsed += name + '="' + value + '";';
                        }
                    } // END: Mode: bundle keys as vars/functions
                } // END: if(pair.length > 0)
            } // END: skip comments
        }
        eval(parsed);
        settings.filesLoaded += 1;
    }
function parseData ( data , settings ) { var parsed = '' ; var lines = data . split ( / \n / ) ; var regPlaceHolder = / (\{\d+}) / g ; var regRepPlaceHolder = / \{(\d+)} / g ; var unicodeRE = / (\\u.{4}) / ig ; for ( var i = 0 , j = lines . length ; i < j ; i ++ ) { var line = lines [ i ] ; line = line . trim ( ) ; if ( line . length > 0 && line . match ( "^#" ) != "#" ) { // skip comments var pair = line . split ( '=' ) ; if ( pair . length > 0 ) { /** Process key & value */ var name = decodeURI ( pair [ 0 ] ) . trim ( ) ; var value = pair . length == 1 ? "" : pair [ 1 ] ; // process multi-line values while ( value . search ( / \\$ / ) != - 1 ) { value = value . substring ( 0 , value . length - 1 ) ; value += lines [ ++ i ] . trimRight ( ) ; } // Put values with embedded '='s back together for ( var s = 2 ; s < pair . length ; s ++ ) { value += '=' + pair [ s ] ; } value = value . trim ( ) ; /** Mode: bundle keys in a map */ if ( settings . mode == 'map' || settings . mode == 'both' ) { // handle unicode chars possibly left out var unicodeMatches = value . match ( unicodeRE ) ; if ( unicodeMatches ) { unicodeMatches . forEach ( function ( match ) { value = value . replace ( match , unescapeUnicode ( match ) ) ; } ) ; } // add to map if ( settings . namespace ) { $ . i18n . map [ settings . namespace ] [ name ] = value ; } else { $ . i18n . map [ name ] = value ; } } /** Mode: bundle keys as vars/functions */ if ( settings . mode == 'vars' || settings . mode == 'both' ) { value = value . replace ( / " / g , '\\"' ) ; // escape quotation mark (") // make sure namespaced key exists (eg, 'some.key') checkKeyNamespace ( name ) ; // value with variable substitutions if ( regPlaceHolder . test ( value ) ) { var parts = value . split ( regPlaceHolder ) ; // process function args var first = true ; var fnArgs = '' ; var usedArgs = [ ] ; parts . forEach ( function ( part ) { if ( regPlaceHolder . test ( part ) && ( usedArgs . length === 0 || usedArgs . indexOf ( part ) == - 1 ) ) { if ( ! first ) { fnArgs += ',' ; } fnArgs += part . replace ( regRepPlaceHolder , 'v$1' ) ; usedArgs . push ( part ) ; first = false ; } } ) ; parsed += name + '=function(' + fnArgs + '){' ; // process function body var fnExpr = '"' + value . replace ( regRepPlaceHolder , '"+v$1+"' ) + '"' ; parsed += 'return ' + fnExpr + ';' + '};' ; // simple value } else { parsed += name + '="' + value + '";' ; } } // END: Mode: bundle keys as vars/functions } // END: if(pair.length > 0) } // END: skip comments } eval ( parsed ) ; settings . filesLoaded += 1 ; }
Parse .properties files
Parse . properties files