Added special characters conversion on file import and export for online translations
This commit is contained in:
parent
ae68588206
commit
37bd35cdfe
1 changed files with 24 additions and 4 deletions
|
@ -121,13 +121,13 @@ class PropInfo {
|
||||||
if (followLine) {
|
if (followLine) {
|
||||||
followLine = isNextLineFollow(lines[i]);
|
followLine = isNextLineFollow(lines[i]);
|
||||||
var lineValue = lines[i].replace(/\\$/, "");
|
var lineValue = lines[i].replace(/\\$/, "");
|
||||||
overridenTranslations.set(lineKey, overridenTranslations.get(lineKey) + lineValue);
|
overridenTranslations.set(lineKey, overridenTranslations.get(lineKey) + unescapeHTML(lineValue));
|
||||||
} else {
|
} else {
|
||||||
followLine = isNextLineFollow(lines[i]);
|
followLine = isNextLineFollow(lines[i]);
|
||||||
lineKey = getLineKey(lines[i]);
|
lineKey = getLineKey(lines[i]);
|
||||||
if (lineKey.trim() != "") {
|
if (lineKey.trim() != "") {
|
||||||
let lineValue = getLineValue(lines[i]);
|
let lineValue = getLineValue(lines[i]);
|
||||||
overridenTranslations.set(lineKey, lineValue);
|
overridenTranslations.set(lineKey, unescapeHTML(lineValue));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,7 @@ class PropInfo {
|
||||||
var fileName = "export_" + date.toLocaleString() + "_all.properties";
|
var fileName = "export_" + date.toLocaleString() + "_all.properties";
|
||||||
var lines = [];
|
var lines = [];
|
||||||
for (let [key, value] of overridenTranslations) {
|
for (let [key, value] of overridenTranslations) {
|
||||||
lines.push(key + " = " + value);
|
lines.push(key + " = " + escapeHTML(value));
|
||||||
}
|
}
|
||||||
saveFile(fileName, lines);
|
saveFile(fileName, lines);
|
||||||
}
|
}
|
||||||
|
@ -266,7 +266,7 @@ class PropInfo {
|
||||||
var value = input.nextSibling.value;
|
var value = input.nextSibling.value;
|
||||||
} else {
|
} else {
|
||||||
var value = input.value;
|
var value = input.value;
|
||||||
if (pageTranslations.get(key).rawText != value) {
|
if (pageTranslations.get(key).rawText != escapeHTML(value)) {
|
||||||
input.style.backgroundColor = "#8BAB2E";
|
input.style.backgroundColor = "#8BAB2E";
|
||||||
overridenTranslations.set(key, value);
|
overridenTranslations.set(key, value);
|
||||||
} else {
|
} else {
|
||||||
|
@ -438,6 +438,26 @@ class PropInfo {
|
||||||
pageTranslations.set(key, propInfo);
|
pageTranslations.set(key, propInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function escapeHTML(input) {
|
||||||
|
return input
|
||||||
|
.replace(/&/g, "&")
|
||||||
|
.replace(/</g, "<")
|
||||||
|
.replace(/>/g, ">")
|
||||||
|
.replace(/"/g, """)
|
||||||
|
.replace(/'/g, "'")
|
||||||
|
.replace(/‘/g, "‘")
|
||||||
|
.replace(/’/g, "’");
|
||||||
|
}
|
||||||
|
function unescapeHTML(input) {
|
||||||
|
return input
|
||||||
|
.replace(/&/g, "&")
|
||||||
|
.replace(/</g, "<")
|
||||||
|
.replace(/>/g, ">")
|
||||||
|
.replace(/"/g, "\"")
|
||||||
|
.replace(/'/g, "'")
|
||||||
|
.replace(/‘/g, "‘")
|
||||||
|
.replace(/’/g, "’");
|
||||||
|
}
|
||||||
|
|
||||||
window.addEventListener('load', function() {
|
window.addEventListener('load', function() {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue