pofile/dist/pofile.min.js
Ruben Vermeersch 16f423879a Rebuild
2017-02-10 17:02:46 +01:00

1 line
4.8 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){function d(a){return a.replace(/^\s+|\s+$/g,"")}var e=a("fs"),f=function(){this.comments=[],this.extractedComments=[],this.headers={},this.items=[]};f.prototype.save=function(a,b){e.writeFile(a,this.toString(),b)},f.prototype.toString=function(){var a=[];this.comments&&this.comments.forEach(function(b){a.push("# "+b)}),this.extractedComments&&this.extractedComments.forEach(function(b){a.push("#. "+b)}),a.push('msgid ""'),a.push('msgstr ""');var b=Object.keys(this.headers),c=this;return b.forEach(function(b){a.push('"'+b+": "+c.headers[b]+'\\n"')}),a.push(""),this.items.forEach(function(b){a.push(b.toString()),a.push("")}),a.join("\n")},f.load=function(a,b){e.readFile(a,"utf-8",function(a,c){if(a)return b(a);var d=f.parse(c);b(null,d)})},f.parse=function(a){function b(){j.msgid.length>0&&(m>=n&&(j.obsolete=!0),m=0,n=0,e.items.push(j),j=new f.Item)}function c(a){return a=d(a),a=a.replace(/^[^"]*"|"$/g,""),a=a.replace(/\\([abtnvfr'"\\?]|([0-7]{3})|x([0-9a-fA-F]{2}))/g,function(a,b,c,d){if(c)return String.fromCharCode(parseInt(c,8));if(d)return String.fromCharCode(parseInt(d,16));switch(b){case"a":return"";case"b":return"\b";case"t":return"\t";case"n":return"\n";case"v":return"\v";case"f":return"\f";case"r":return"\r";default:return b}})}a=a.replace(/\r\n/g,"\n");for(var e=new f,g=a.split(/\n\n/),h=[];g[0]&&(0===h.length||h[h.length-1].indexOf('msgid ""')<0);)g[0].match(/msgid "[^"]/)?h.push('msgid ""'):h.push(g.shift());h=h.join("\n");var i=g.join("\n").split(/\n/);e.headers={"Project-Id-Version":"","Report-Msgid-Bugs-To":"","POT-Creation-Date":"","PO-Revision-Date":"","Last-Translator":"",Language:"","Language-Team":"","Content-Type":"","Content-Transfer-Encoding":"","Plural-Forms":""},h.split(/\n/).reduce(function(a,b){return a.merge&&(b=a.pop().slice(0,-1)+b.slice(1),delete a.merge),/^".*"$/.test(b)&&!/^".*\\n"$/.test(b)&&(a.merge=!0),a.push(b),a},[]).forEach(function(a){if(a.match(/^#\./))e.extractedComments.push(a.replace(/^#\.\s*/,""));else if(a.match(/^#/))e.comments.push(a.replace(/^#\s*/,""));else if(a.match(/^"/)){a=a.trim().replace(/^"/,"").replace(/\\n"$/,"");var b=a.split(/:/),c=b.shift().trim(),d=b.join(":").trim();e.headers[c]=d}});for(var j=new f.Item,k=null,l=0,m=0,n=0;i.length>0;){var o=d(i.shift()),p=!1;if(o.match(/^#\~/)&&(o=d(o.substring(2)),p=!0),o.match(/^#:/))b(),j.references.push(d(o.replace(/^#:/,"")));else if(o.match(/^#,/)){b();for(var q=d(o.replace(/^#,/,"")).split(","),r=0;r<q.length;r++)j.flags[q[r]]=!0}else if(o.match(/^#($|\s+)/))b(),j.comments.push(d(o.replace(/^#($|\s+)/,"")));else if(o.match(/^#\./))b(),j.extractedComments.push(d(o.replace(/^#\./,"")));else if(o.match(/^msgid_plural/))j.msgid_plural=c(o),k="msgid_plural",n++;else if(o.match(/^msgid/))b(),j.msgid=c(o),k="msgid",n++;else if(o.match(/^msgstr/)){var s=o.match(/^msgstr\[(\d+)\]/);l=s&&s[1]?parseInt(s[1]):0,j.msgstr[l]=c(o),k="msgstr",n++}else o.match(/^msgctxt/)?(b(),j.msgctxt=c(o),n++):o.length>0&&(n++,"msgstr"===k?j.msgstr[l]+=c(o):"msgid"===k?j.msgid+=c(o):"msgid_plural"===k&&(j.msgid_plural+=c(o)));p&&m++}return b(),e},f.Item=function(){this.msgid="",this.msgctxt=null,this.references=[],this.msgid_plural=null,this.msgstr=[],this.comments=[],this.extractedComments=[],this.flags={},this.obsolete=!1},f.Item.prototype.toString=function(){var a=[],b=this,c=function(a){return a=a.replace(/[\x07\b\t\v\f\r"\\]/g,function(a){switch(a){case"":return"\\a";case"\b":return"\\b";case"\t":return"\\t";case"\v":return"\\v";case"\f":return"\\f";case"\r":return"\\r";default:return"\\"+a}})},d=function(a,b,d){var e=[],f=b.split(/\n/),g="undefined"!=typeof d?"["+d+"]":"";return f.length>1?(e.push(a+g+' ""'),f.forEach(function(a){e.push('"'+c(a)+'"')})):e.push(a+g+' "'+c(b)+'"'),e};this.comments.forEach(function(b){a.push("# "+b)}),this.extractedComments.forEach(function(b){a.push("#. "+b)}),this.references.forEach(function(b){a.push("#: "+b)});var e=Object.keys(this.flags).filter(function(a){return!!this.flags[a]},this);e.length>0&&a.push("#, "+e.join(","));var f=this.obsolete?"#~ ":"";return["msgctxt","msgid","msgid_plural","msgstr"].forEach(function(c){var e=b[c];if(null!=e)if(Array.isArray(e)&&e.length>1)e.forEach(function(b,e){a=a.concat(f+d(c,b,e))});else{var g=b.msgid_plural&&Array.isArray(e)?0:void 0;e=Array.isArray(e)?e.join():e;for(var h=d(c,e,g),i=1;i<h.length-1;i++)h[i]=h[i].slice(0,-1)+'\\n"';a=a.concat(f+h.join("\n"+f))}}),a.join("\n")},b.exports=f},{fs:2}],2:[function(a,b,c){},{}]},{},[1]);