mtranserver 4.0.19 → 4.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/engine.d.ts +2 -0
- package/dist/core/engine.d.ts.map +1 -1
- package/dist/icon-tjp1feba.png +0 -0
- package/dist/index-B7vzjIqN-ma6ncj8z.css +1 -0
- package/dist/index-D6lVFqDO-3a1nn40g.js +53 -0
- package/dist/{index-wzc7qnpt.html → index-g3cdpfvc.html} +2 -2
- package/dist/index.js +29 -3
- package/dist/index.js.map +3 -3
- package/dist/main.js +59 -33
- package/dist/main.js.map +6 -6
- package/package.json +8 -7
- package/dist/icon-2r5te9sp.png +0 -0
- package/dist/index-B5MwS93W-8btbkjwj.css +0 -1
- package/dist/index-CViVzJTS-xrkq8wea.js +0 -53
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<meta name="darkreader-lock" />
|
|
8
8
|
<title>MTranServer</title>
|
|
9
|
-
<script type="module" crossorigin src="/ui/assets/index-
|
|
10
|
-
<link rel="stylesheet" crossorigin href="/ui/assets/index-
|
|
9
|
+
<script type="module" crossorigin src="/ui/assets/index-D6lVFqDO.js"></script>
|
|
10
|
+
<link rel="stylesheet" crossorigin href="/ui/assets/index-B7vzjIqN.css">
|
|
11
11
|
</head>
|
|
12
12
|
<body>
|
|
13
13
|
<div id="root"></div>
|
package/dist/index.js
CHANGED
|
@@ -1312,7 +1312,8 @@ class TranslationEngine {
|
|
|
1312
1312
|
if (options.html) {
|
|
1313
1313
|
processedText = this._sanitizeHTML(text);
|
|
1314
1314
|
}
|
|
1315
|
-
const { cleanText, replacements } = this.
|
|
1315
|
+
const { cleanText: placeholderText, replacements: placeholderReplacements } = this._hidePlaceholders(processedText, options);
|
|
1316
|
+
const { cleanText, replacements } = this._hideEmojis(placeholderText);
|
|
1316
1317
|
let translation;
|
|
1317
1318
|
try {
|
|
1318
1319
|
if (cleanText.length > this.maxLengthBreak) {
|
|
@@ -1328,6 +1329,7 @@ class TranslationEngine {
|
|
|
1328
1329
|
throw error2;
|
|
1329
1330
|
}
|
|
1330
1331
|
translation = this._restoreEmojis(translation, replacements);
|
|
1332
|
+
translation = this._restorePlaceholders(translation, placeholderReplacements);
|
|
1331
1333
|
return translation;
|
|
1332
1334
|
}
|
|
1333
1335
|
_sanitizeHTML(text) {
|
|
@@ -1484,6 +1486,30 @@ class TranslationEngine {
|
|
|
1484
1486
|
}
|
|
1485
1487
|
return result;
|
|
1486
1488
|
}
|
|
1489
|
+
_hidePlaceholders(text, options = {}) {
|
|
1490
|
+
const replacements = [];
|
|
1491
|
+
const used = new Set;
|
|
1492
|
+
const placeholderRegex = /(\{\d+\}|\[\d+\])/g;
|
|
1493
|
+
const cleanText = text.replace(placeholderRegex, (match) => {
|
|
1494
|
+
let placeholder = `__MTRAN_PH_${replacements.length}__`;
|
|
1495
|
+
let salt = 0;
|
|
1496
|
+
while (text.includes(placeholder) || used.has(placeholder)) {
|
|
1497
|
+
salt += 1;
|
|
1498
|
+
placeholder = `__MTRAN_PH_${replacements.length}_${salt}__`;
|
|
1499
|
+
}
|
|
1500
|
+
used.add(placeholder);
|
|
1501
|
+
replacements.push({ original: match, placeholder });
|
|
1502
|
+
return placeholder;
|
|
1503
|
+
});
|
|
1504
|
+
return { cleanText, replacements };
|
|
1505
|
+
}
|
|
1506
|
+
_restorePlaceholders(text, replacements) {
|
|
1507
|
+
let result = text;
|
|
1508
|
+
for (const { original, placeholder } of replacements) {
|
|
1509
|
+
result = result.split(placeholder).join(original);
|
|
1510
|
+
}
|
|
1511
|
+
return result;
|
|
1512
|
+
}
|
|
1487
1513
|
destroy() {
|
|
1488
1514
|
try {
|
|
1489
1515
|
if (this.model) {
|
|
@@ -4400,7 +4426,7 @@ var init_bergamot_translator = () => {};
|
|
|
4400
4426
|
|
|
4401
4427
|
// src/lib/cld2/cld2.js
|
|
4402
4428
|
var require_cld2 = __commonJS((exports, module) => {
|
|
4403
|
-
var __dirname = "/
|
|
4429
|
+
var __dirname = "/home/xxnuo/projects/MTran/MTranServer/src/lib/cld2", __filename = "/home/xxnuo/projects/MTran/MTranServer/src/lib/cld2/cld2.js";
|
|
4404
4430
|
var loadCLD2 = (() => {
|
|
4405
4431
|
var _scriptName = globalThis.document?.currentScript?.src;
|
|
4406
4432
|
return async function(moduleArg = {}) {
|
|
@@ -7400,5 +7426,5 @@ export {
|
|
|
7400
7426
|
MTran
|
|
7401
7427
|
};
|
|
7402
7428
|
|
|
7403
|
-
//# debugId=
|
|
7429
|
+
//# debugId=F76793A5334DBD8464756E2164756E21
|
|
7404
7430
|
//# sourceMappingURL=index.js.map
|