@ragnoryok1/dsh-client-locale-ru 0.2.13 → 0.2.15
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/CHANGELOG.md +1556 -1370
- package/NAMESPACES.md +504 -50
- package/README.en.md +600 -598
- package/README.md +599 -608
- package/README.zh.md +296 -293
- package/lib/client.js +54993 -266
- package/lib/index.d.ts +46 -7
- package/lib/index.js +101 -7
- package/package.json +2 -2
package/lib/index.d.ts
CHANGED
|
@@ -1,11 +1,50 @@
|
|
|
1
|
+
import { Context } from "@deepseek-ai/cordis";
|
|
2
|
+
//#region src/options.d.ts
|
|
3
|
+
/** Switches for the passes the pack runs on top of its dictionaries. */
|
|
4
|
+
interface Options {
|
|
5
|
+
/** Russian screen typography: «ёлочки», em dashes, ellipses, non-breaking spaces. */
|
|
6
|
+
typography?: boolean;
|
|
7
|
+
/** Russian plural forms picked by `Intl.PluralRules('ru')` instead of the neutral label. */
|
|
8
|
+
plurals?: boolean;
|
|
9
|
+
/** Russian titles and descriptions for plugins whose package ships no Russian locale. */
|
|
10
|
+
pluginNames?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/** What a Standard Schema validation answers: the normalized options, or the reasons it is not one. */
|
|
13
|
+
type ValidationResult = {
|
|
14
|
+
value: Options;
|
|
15
|
+
} | {
|
|
16
|
+
issues: {
|
|
17
|
+
message: string;
|
|
18
|
+
}[];
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Config schema without a runtime dependency.
|
|
22
|
+
*
|
|
23
|
+
* The loader accepts any Standard Schema (`~standard.validate`), and this pack ships no
|
|
24
|
+
* dependencies on purpose — a language pack that pulls a validator into every profile
|
|
25
|
+
* to read three booleans is a bad trade. An unknown switch is an error rather than a
|
|
26
|
+
* silent no-op: a typo in `typografy: false` would otherwise leave the pass running and
|
|
27
|
+
* look like the option does not work.
|
|
28
|
+
*/
|
|
29
|
+
declare const Config: {
|
|
30
|
+
'~standard': {
|
|
31
|
+
version: 1;
|
|
32
|
+
vendor: string;
|
|
33
|
+
validate(value: unknown): ValidationResult;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
//#endregion
|
|
1
37
|
//#region src/index.d.ts
|
|
2
38
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* the
|
|
6
|
-
*
|
|
39
|
+
* Host plugin body.
|
|
40
|
+
*
|
|
41
|
+
* `webServer` is optional on purpose: the pack also loads on surfaces that serve no
|
|
42
|
+
* HTML (a desktop shell, a headless boot), and requiring the service there would keep
|
|
43
|
+
* the whole plugin from activating — dictionaries and all.
|
|
44
|
+
*
|
|
45
|
+
* @param ctx - host root context.
|
|
46
|
+
* @param config - the switches from the profile row; omitted means all on.
|
|
7
47
|
*/
|
|
8
|
-
|
|
9
|
-
declare function apply(): void;
|
|
48
|
+
declare function apply(ctx: Context, config?: Options): void;
|
|
10
49
|
//#endregion
|
|
11
|
-
export { apply };
|
|
50
|
+
export { Config, type Options, apply };
|
package/lib/index.js
CHANGED
|
@@ -1,11 +1,105 @@
|
|
|
1
|
+
//#region src/options.ts
|
|
2
|
+
/**
|
|
3
|
+
* The switches that turn the pack's extra passes off.
|
|
4
|
+
*
|
|
5
|
+
* The pack is more than a dictionary: it substitutes Russian plural forms, rewrites
|
|
6
|
+
* plugin titles the harness cannot translate, and applies Russian screen typography.
|
|
7
|
+
* Each extra can disagree with a reader who wants only the translation — typography
|
|
8
|
+
* in particular rewrites text the user may have typed into a form or a prompt. A
|
|
9
|
+
* switch disables one pass without touching the dictionaries, so the interface stays
|
|
10
|
+
* Russian and only the extra behaviour disappears.
|
|
11
|
+
*
|
|
12
|
+
* The switches arrive from the profile's `cordis.yml` row:
|
|
13
|
+
*
|
|
14
|
+
* ```yaml
|
|
15
|
+
* - id: locale-ru
|
|
16
|
+
* config:
|
|
17
|
+
* typography: false
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* The browser half cannot read that row — the client boot graph carries no config —
|
|
21
|
+
* so the host half hands the resolved switches to the page through the webserver's
|
|
22
|
+
* index-injection table (see `src/index.ts`), and the browser half reads the global
|
|
23
|
+
* this module names. Omitting a switch means «on», so an existing profile needs no
|
|
24
|
+
* edit, and a surface without the webserver simply keeps the defaults.
|
|
25
|
+
*/
|
|
26
|
+
/** The switches, by their name in the config. */
|
|
27
|
+
const SWITCHES = [
|
|
28
|
+
"typography",
|
|
29
|
+
"plurals",
|
|
30
|
+
"pluginNames"
|
|
31
|
+
];
|
|
32
|
+
/** The global the host half writes and the browser half reads. */
|
|
33
|
+
const BOOT_OPTIONS_KEY = "__DSH_RU_OPTIONS__";
|
|
34
|
+
/**
|
|
35
|
+
* Config schema without a runtime dependency.
|
|
36
|
+
*
|
|
37
|
+
* The loader accepts any Standard Schema (`~standard.validate`), and this pack ships no
|
|
38
|
+
* dependencies on purpose — a language pack that pulls a validator into every profile
|
|
39
|
+
* to read three booleans is a bad trade. An unknown switch is an error rather than a
|
|
40
|
+
* silent no-op: a typo in `typografy: false` would otherwise leave the pass running and
|
|
41
|
+
* look like the option does not work.
|
|
42
|
+
*/
|
|
43
|
+
const Config = { "~standard": {
|
|
44
|
+
version: 1,
|
|
45
|
+
vendor: "dsh-client-locale-ru",
|
|
46
|
+
validate(value) {
|
|
47
|
+
if (value === void 0 || value === null) return { value: {} };
|
|
48
|
+
if (typeof value !== "object" || Array.isArray(value)) return { issues: [{ message: `опции пакета — объект: ${SWITCHES.join(", ")}` }] };
|
|
49
|
+
const source = value;
|
|
50
|
+
const unknown = Object.keys(source).filter((key) => !SWITCHES.includes(key));
|
|
51
|
+
if (unknown.length > 0) return { issues: [{ message: `неизвестные опции: ${unknown.join(", ")}; известны: ${SWITCHES.join(", ")}` }] };
|
|
52
|
+
const normalized = {};
|
|
53
|
+
for (const key of SWITCHES) {
|
|
54
|
+
const raw = source[key];
|
|
55
|
+
if (raw === void 0) continue;
|
|
56
|
+
if (typeof raw !== "boolean") return { issues: [{ message: `${key} — true или false, получено ${typeof raw}` }] };
|
|
57
|
+
normalized[key] = raw;
|
|
58
|
+
}
|
|
59
|
+
return { value: normalized };
|
|
60
|
+
}
|
|
61
|
+
} };
|
|
62
|
+
/**
|
|
63
|
+
* Normalize any candidate into the switches the passes read.
|
|
64
|
+
*
|
|
65
|
+
* Only booleans count: a switch that arrived as a string (`"false"`, a common YAML
|
|
66
|
+
* mistake) is ignored rather than treated as a truthy value, because «off» and «on»
|
|
67
|
+
* must not depend on how generous a cast was.
|
|
68
|
+
*
|
|
69
|
+
* @param value - the candidate, typically the row config or the injected global.
|
|
70
|
+
* @returns the switches that were explicitly set.
|
|
71
|
+
*/
|
|
72
|
+
function normalizeOptions(value) {
|
|
73
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return {};
|
|
74
|
+
const source = value;
|
|
75
|
+
const normalized = {};
|
|
76
|
+
for (const key of SWITCHES) {
|
|
77
|
+
const raw = source[key];
|
|
78
|
+
if (typeof raw === "boolean") normalized[key] = raw;
|
|
79
|
+
}
|
|
80
|
+
return normalized;
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
1
83
|
//#region src/index.ts
|
|
2
84
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* the
|
|
6
|
-
*
|
|
85
|
+
* Host plugin body.
|
|
86
|
+
*
|
|
87
|
+
* `webServer` is optional on purpose: the pack also loads on surfaces that serve no
|
|
88
|
+
* HTML (a desktop shell, a headless boot), and requiring the service there would keep
|
|
89
|
+
* the whole plugin from activating — dictionaries and all.
|
|
90
|
+
*
|
|
91
|
+
* @param ctx - host root context.
|
|
92
|
+
* @param config - the switches from the profile row; omitted means all on.
|
|
7
93
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
94
|
+
function apply(ctx, config = {}) {
|
|
95
|
+
const options = normalizeOptions(config);
|
|
96
|
+
ctx.on("webserver/index-inject", (table) => {
|
|
97
|
+
table.push({
|
|
98
|
+
kind: "global",
|
|
99
|
+
name: BOOT_OPTIONS_KEY,
|
|
100
|
+
value: options
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
}
|
|
10
104
|
//#endregion
|
|
11
|
-
export { apply };
|
|
105
|
+
export { Config, apply };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ragnoryok1/dsh-client-locale-ru",
|
|
3
|
-
"description": "
|
|
4
|
-
"version": "0.2.
|
|
3
|
+
"description": "Russian (ru) interface for the DeepSeek Harness web GUI: 584 namespaces, 67724 strings, 520 third-party plugin dictionaries, ru plural forms and screen typography. Hybrid dsh.bundle + dsh.client plugin.",
|
|
4
|
+
"version": "0.2.15",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|
|
7
7
|
"deepseek-harness",
|