Rebuild for #12.
This commit is contained in:
parent
e42dc28fd2
commit
b499b7f449
55
dist/pofile.js
vendored
55
dist/pofile.js
vendored
@ -120,8 +120,32 @@ PO.parse = function (data) {
|
|||||||
function extract(string) {
|
function extract(string) {
|
||||||
string = trim(string);
|
string = trim(string);
|
||||||
string = string.replace(/^[^"]*"|"$/g, '');
|
string = string.replace(/^[^"]*"|"$/g, '');
|
||||||
string = string.replace(/\\"/g, '"');
|
string = string.replace(/\\([abtnvfr'"\\?]|([0-7]{3})|x([0-9a-fA-F]{2}))/g, function (match, esc, oct, hex) {
|
||||||
string = string.replace(/\\\\/g, '\\');
|
if (oct) {
|
||||||
|
return String.fromCharCode(parseInt(oct, 8));
|
||||||
|
}
|
||||||
|
if (hex) {
|
||||||
|
return String.fromCharCode(parseInt(hex, 16));
|
||||||
|
}
|
||||||
|
switch (esc) {
|
||||||
|
case 'a':
|
||||||
|
return '\x07';
|
||||||
|
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 esc;
|
||||||
|
}
|
||||||
|
});
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,8 +237,27 @@ PO.Item.prototype.toString = function () {
|
|||||||
|
|
||||||
// reverse what extract(string) method during PO.parse does
|
// reverse what extract(string) method during PO.parse does
|
||||||
var _escape = function (string) {
|
var _escape = function (string) {
|
||||||
string = string.replace(/\\/g, '\\\\');
|
// don't unescape \n, since string can never contain it
|
||||||
return string.replace(/"/g, '\\"');
|
// since split('\n') is called on it
|
||||||
|
string = string.replace(/[\x07\b\t\v\f\r"\\]/g, function (match) {
|
||||||
|
switch (match) {
|
||||||
|
case '\x07':
|
||||||
|
return '\\a';
|
||||||
|
case '\b':
|
||||||
|
return '\\b';
|
||||||
|
case '\t':
|
||||||
|
return '\\t';
|
||||||
|
case '\v':
|
||||||
|
return '\\v';
|
||||||
|
case '\f':
|
||||||
|
return '\\f';
|
||||||
|
case '\r':
|
||||||
|
return '\\r';
|
||||||
|
default:
|
||||||
|
return '\\' + match;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return string;
|
||||||
};
|
};
|
||||||
|
|
||||||
var _process = function (keyword, text, i) {
|
var _process = function (keyword, text, i) {
|
||||||
@ -263,6 +306,10 @@ PO.Item.prototype.toString = function () {
|
|||||||
} else {
|
} else {
|
||||||
text = isArray(text) ? text.join() : text;
|
text = isArray(text) ? text.join() : text;
|
||||||
var processed = _process(keyword, text);
|
var processed = _process(keyword, text);
|
||||||
|
//handle \n in single-line texts (can not be handled in _escape)
|
||||||
|
for (var i = 1; i < processed.length - 1; i++) {
|
||||||
|
processed[i] = processed[i].slice(0, -1) + '\\n"';
|
||||||
|
}
|
||||||
lines = lines.concat(mkObsolete + processed.join('\n' + mkObsolete));
|
lines = lines.concat(mkObsolete + processed.join('\n' + mkObsolete));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
dist/pofile.min.js
vendored
2
dist/pofile.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user