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) {
|
||||
followLine = isNextLineFollow(lines[i]);
|
||||
var lineValue = lines[i].replace(/\\$/, "");
|
||||
overridenTranslations.set(lineKey, overridenTranslations.get(lineKey) + lineValue);
|
||||
overridenTranslations.set(lineKey, overridenTranslations.get(lineKey) + unescapeHTML(lineValue));
|
||||
} else {
|
||||
followLine = isNextLineFollow(lines[i]);
|
||||
lineKey = getLineKey(lines[i]);
|
||||
if (lineKey.trim() != "") {
|
||||
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 lines = [];
|
||||
for (let [key, value] of overridenTranslations) {
|
||||
lines.push(key + " = " + value);
|
||||
lines.push(key + " = " + escapeHTML(value));
|
||||
}
|
||||
saveFile(fileName, lines);
|
||||
}
|
||||
|
@ -266,7 +266,7 @@ class PropInfo {
|
|||
var value = input.nextSibling.value;
|
||||
} else {
|
||||
var value = input.value;
|
||||
if (pageTranslations.get(key).rawText != value) {
|
||||
if (pageTranslations.get(key).rawText != escapeHTML(value)) {
|
||||
input.style.backgroundColor = "#8BAB2E";
|
||||
overridenTranslations.set(key, value);
|
||||
} else {
|
||||
|
@ -438,6 +438,26 @@ class 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() {
|
||||
setTimeout(function() {
|
||||
|
|
Loading…
Add table
Reference in a new issue