@goodandready/dsh-russian-lang 0.3.8 → 0.3.9
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/README.md +20 -1
- package/lib/client.js +18 -14
- package/lib/client.template.js +6 -7
- package/lib/locales/core.json +1 -1
- package/lib/pure.js +6 -11
- package/lib/translator.js +5 -7
- package/package.json +1 -1
package/lib/pure.js
CHANGED
|
@@ -468,23 +468,18 @@ const SHORT_WORDS_RE = /(^|[\s(«])([вВнНсСпПоОкКуУиИаА]|из|
|
|
|
468
468
|
*/
|
|
469
469
|
export const formatInputLive = (text) => {
|
|
470
470
|
if (!text || typeof text !== 'string') return text
|
|
471
|
-
|
|
472
|
-
// Разбиваем по блокам кода (inline `...` или fenced ```...```), чтобы не портить синтаксис
|
|
473
471
|
const parts = text.split(/(```[\s\S]*?```|`[^`\n]*`)/g)
|
|
474
472
|
for (let i = 0; i < parts.length; i += 2) {
|
|
475
473
|
let s = parts[i]
|
|
476
474
|
if (!s) continue
|
|
477
|
-
|
|
478
|
-
|
|
475
|
+
const lq = [], cf = []
|
|
476
|
+
s = s.replace(/"([^"\n]*[a-zA-Z][^"\n]*)"/g, (m) => `\x01L${lq.push(m) - 1}\x01`)
|
|
477
|
+
s = s.replace(/(^|\s)(--[a-zA-Z0-9_\u0400-\u04FF-]+)/g, (m, p1, p2) => `${p1}\x01C${cf.push(p2) - 1}\x01`)
|
|
478
|
+
s = s.replace(/(^|\s)(--)(?=\s|$)/g, (m, p1, p2) => /[a-zA-Z]/.test(text) ? `${p1}\x01C${cf.push(p2) - 1}\x01` : m)
|
|
479
479
|
s = s.replace(/--/g, '—')
|
|
480
|
-
|
|
481
|
-
// 3. Кавычки-ёлочки («...») с учётом открывающейся/закрывающейся
|
|
482
|
-
s = s.replace(/(^|[\s([{-])"/g, '$1«')
|
|
483
|
-
s = s.replace(/"/g, '»')
|
|
484
|
-
|
|
485
|
-
// 4. Неразрывный пробел после коротких слов/предлогов
|
|
480
|
+
s = s.replace(/(^|[\s([{-])"/g, '$1«').replace(/"/g, '»')
|
|
486
481
|
s = s.replace(SHORT_WORDS_RE, '$1$2\u00A0')
|
|
487
|
-
|
|
482
|
+
s = s.replace(/\x01C(\d+)\x01/g, (_, j) => cf[+j]).replace(/\x01L(\d+)\x01/g, (_, j) => lq[+j])
|
|
488
483
|
parts[i] = s
|
|
489
484
|
}
|
|
490
485
|
return parts.join('')
|
package/lib/translator.js
CHANGED
|
@@ -54,7 +54,6 @@ export const TRANSLATOR_HEADER = 'x-dsh-translator'
|
|
|
54
54
|
|
|
55
55
|
export function isTrustedTranslatorRequest(request) {
|
|
56
56
|
if (header(request, TRANSLATOR_HEADER) !== '1') return false
|
|
57
|
-
if (!isLoopback(request?.socket?.remoteAddress)) return false
|
|
58
57
|
const site = header(request, 'sec-fetch-site')
|
|
59
58
|
if (site !== undefined && site !== 'same-origin') return false
|
|
60
59
|
const origin = header(request, 'origin')
|
|
@@ -62,11 +61,10 @@ export function isTrustedTranslatorRequest(request) {
|
|
|
62
61
|
if (origin === undefined || host === undefined) return false
|
|
63
62
|
try {
|
|
64
63
|
const url = new URL(origin)
|
|
65
|
-
return
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
)
|
|
64
|
+
if (url.protocol !== 'http:' && url.protocol !== 'https:') return false
|
|
65
|
+
// Same-origin check: Origin host must match Host header.
|
|
66
|
+
// Accepts loopback, LAN, and Tailscale addresses alike.
|
|
67
|
+
return url.host === host
|
|
70
68
|
} catch {
|
|
71
69
|
return false
|
|
72
70
|
}
|
|
@@ -136,7 +134,7 @@ export async function setupLibreTranslateContainer() {
|
|
|
136
134
|
'--name', 'libretranslate',
|
|
137
135
|
'--restart', 'unless-stopped',
|
|
138
136
|
'-p', '127.0.0.1:5000:5000',
|
|
139
|
-
'libretranslate/libretranslate',
|
|
137
|
+
'libretranslate/libretranslate:v1.5.3',
|
|
140
138
|
'--load-only', 'en,ru,zh'
|
|
141
139
|
], 30000)
|
|
142
140
|
return { ok: true, action: 'created', message: 'Контейнер libretranslate создан и запускается (~600 МБ RAM).' }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goodandready/dsh-russian-lang",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.9",
|
|
4
4
|
"description": "Russian localization for DeepSeek Harness (DSH v0.1.7-rc.1+) web UI: adds Русский as native language option. 100.0% coverage across 11,295 keys (127 namespaces). Features full DSH v0.1.7-rc.1 core support (terminal, archive, command palette, Auto review, trajectory, PTC/Creator presets) and complete GoodAndReady plugin catalog (subscriptions, tts, image-gen, voice, key-limits, notify, commandcode, plugin-console).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|