@yadsh/dsh-l10n-overrides 0.1.0
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/LICENSE +21 -0
- package/README.md +83 -0
- package/ROADMAP.md +35 -0
- package/cordis.patch.yml +4 -0
- package/lib/client.js +1207 -0
- package/lib/index.js +4 -0
- package/lib/types/adapters/dsh-locale-runtime.d.ts +26 -0
- package/lib/types/client/index.d.ts +15 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/packs/example.d.ts +25 -0
- package/lib/types/packs/index.d.ts +24 -0
- package/lib/types/registry/diagnostics.d.ts +15 -0
- package/lib/types/registry/translation-registry.d.ts +21 -0
- package/lib/types/runtime/dom-translator.d.ts +10 -0
- package/lib/types/runtime/interpolate.d.ts +1 -0
- package/lib/types/runtime/locale-hook.d.ts +3 -0
- package/lib/types/types.d.ts +28 -0
- package/package.json +95 -0
package/lib/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type LocaleTranslateArguments = [
|
|
2
|
+
namespace: string,
|
|
3
|
+
key: string,
|
|
4
|
+
params?: Record<string, unknown>
|
|
5
|
+
];
|
|
6
|
+
export type LocaleTranslate = (...args: LocaleTranslateArguments) => unknown;
|
|
7
|
+
export type AdapterResult<T> = {
|
|
8
|
+
readonly ok: true;
|
|
9
|
+
readonly value: T;
|
|
10
|
+
} | {
|
|
11
|
+
readonly ok: false;
|
|
12
|
+
};
|
|
13
|
+
export type LocaleInstallResult = {
|
|
14
|
+
readonly ok: true;
|
|
15
|
+
} | {
|
|
16
|
+
readonly ok: false;
|
|
17
|
+
readonly runtimeMayBePatched: boolean;
|
|
18
|
+
};
|
|
19
|
+
export interface DshLocaleRuntimeAdapter {
|
|
20
|
+
readonly runtime: object;
|
|
21
|
+
getActiveLocale(): AdapterResult<string>;
|
|
22
|
+
callOriginal(args: LocaleTranslateArguments): unknown;
|
|
23
|
+
install(wrapper: LocaleTranslate): LocaleInstallResult;
|
|
24
|
+
restoreOriginalIfCurrent(wrapper: LocaleTranslate): AdapterResult<"restored" | "replaced">;
|
|
25
|
+
}
|
|
26
|
+
export declare function adaptDshLocaleRuntime(value: unknown): DshLocaleRuntimeAdapter | undefined;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Context } from "@deepseek-ai/cordis";
|
|
2
|
+
export type { DomTranslationAttribute, DomTranslationRule, TranslationPack, } from "../types.js";
|
|
3
|
+
export interface ClientLogger {
|
|
4
|
+
info(message: string): void;
|
|
5
|
+
warn(message: string): void;
|
|
6
|
+
error(message: string): void;
|
|
7
|
+
debug(message: string): void;
|
|
8
|
+
}
|
|
9
|
+
export interface ClientOptions {
|
|
10
|
+
readonly debug?: boolean;
|
|
11
|
+
readonly document?: Document | null;
|
|
12
|
+
readonly logger?: ClientLogger;
|
|
13
|
+
}
|
|
14
|
+
export declare const inject: string[];
|
|
15
|
+
export declare function apply(ctx: Context, options?: ClientOptions): () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function apply(): void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
declare const example: Readonly<{
|
|
2
|
+
id: "example-plugin-en";
|
|
3
|
+
target: Readonly<{
|
|
4
|
+
package: "dsh-example-plugin";
|
|
5
|
+
versions: ">=0.4.0 <1.0.0";
|
|
6
|
+
}>;
|
|
7
|
+
en: Readonly<{
|
|
8
|
+
"example.settings": Readonly<{
|
|
9
|
+
title: "Settings";
|
|
10
|
+
enabled: "Enabled";
|
|
11
|
+
server: "Server address";
|
|
12
|
+
save: "Save";
|
|
13
|
+
}>;
|
|
14
|
+
}>;
|
|
15
|
+
dom: readonly Readonly<{
|
|
16
|
+
scope: "[data-plugin=\"example-plugin\"]";
|
|
17
|
+
source: "设置";
|
|
18
|
+
target: "Settings";
|
|
19
|
+
}>[];
|
|
20
|
+
metadata: Readonly<{
|
|
21
|
+
sourceLanguage: "zh";
|
|
22
|
+
description: "Example English translation pack";
|
|
23
|
+
}>;
|
|
24
|
+
}>;
|
|
25
|
+
export default example;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const translationPacks: readonly Readonly<{
|
|
2
|
+
id: "example-plugin-en";
|
|
3
|
+
target: Readonly<{
|
|
4
|
+
package: "dsh-example-plugin";
|
|
5
|
+
versions: ">=0.4.0 <1.0.0";
|
|
6
|
+
}>;
|
|
7
|
+
en: Readonly<{
|
|
8
|
+
"example.settings": Readonly<{
|
|
9
|
+
title: "Settings";
|
|
10
|
+
enabled: "Enabled";
|
|
11
|
+
server: "Server address";
|
|
12
|
+
save: "Save";
|
|
13
|
+
}>;
|
|
14
|
+
}>;
|
|
15
|
+
dom: readonly Readonly<{
|
|
16
|
+
scope: "[data-plugin=\"example-plugin\"]";
|
|
17
|
+
source: "设置";
|
|
18
|
+
target: "Settings";
|
|
19
|
+
}>[];
|
|
20
|
+
metadata: Readonly<{
|
|
21
|
+
sourceLanguage: "zh";
|
|
22
|
+
description: "Example English translation pack";
|
|
23
|
+
}>;
|
|
24
|
+
}>[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DiagnosticEntry } from "../types.js";
|
|
2
|
+
type DiagnosticLogger = Pick<Console, "info" | "warn" | "error" | "debug">;
|
|
3
|
+
export declare class Diagnostics {
|
|
4
|
+
#private;
|
|
5
|
+
private readonly logger;
|
|
6
|
+
constructor(logger?: DiagnosticLogger, options?: {
|
|
7
|
+
readonly debug?: boolean;
|
|
8
|
+
});
|
|
9
|
+
info(code: string, message: string): void;
|
|
10
|
+
warning(code: string, message: string): void;
|
|
11
|
+
error(code: string, message: string): void;
|
|
12
|
+
debug(code: string, message: string): void;
|
|
13
|
+
snapshot(): readonly DiagnosticEntry[];
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Diagnostics } from "./diagnostics.js";
|
|
2
|
+
import type { DomTranslationRule, TranslationPack } from "../types.js";
|
|
3
|
+
export interface TranslationRegistryEntry {
|
|
4
|
+
readonly value: string;
|
|
5
|
+
readonly packId: string;
|
|
6
|
+
}
|
|
7
|
+
export interface TranslationRegistryStats {
|
|
8
|
+
readonly packs: number;
|
|
9
|
+
readonly localeOverrides: number;
|
|
10
|
+
readonly domRules: number;
|
|
11
|
+
}
|
|
12
|
+
export declare class TranslationPackRegistry {
|
|
13
|
+
#private;
|
|
14
|
+
private readonly diagnostics;
|
|
15
|
+
constructor(diagnostics: Diagnostics);
|
|
16
|
+
register(pack: TranslationPack): void;
|
|
17
|
+
resolve(locale: string, namespace: string, key: string): string | undefined;
|
|
18
|
+
resolveEntry(locale: string, namespace: string, key: string): TranslationRegistryEntry | undefined;
|
|
19
|
+
getStats(): TranslationRegistryStats;
|
|
20
|
+
getDomRules(locale: string): readonly DomTranslationRule[];
|
|
21
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Diagnostics } from "../registry/diagnostics.js";
|
|
2
|
+
import type { DomTranslationRule } from "../types.js";
|
|
3
|
+
export declare class DomTranslator {
|
|
4
|
+
#private;
|
|
5
|
+
private readonly document;
|
|
6
|
+
private readonly diagnostics;
|
|
7
|
+
constructor(document: Document, rules: readonly DomTranslationRule[], diagnostics: Diagnostics);
|
|
8
|
+
setLocale(locale: string): void;
|
|
9
|
+
dispose(): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function interpolate(template: string, params?: Record<string, unknown>): string;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Diagnostics } from "../registry/diagnostics.js";
|
|
2
|
+
import { TranslationPackRegistry } from "../registry/translation-registry.js";
|
|
3
|
+
export declare function installLocaleHook(runtime: unknown, registry: TranslationPackRegistry, diagnostics: Diagnostics): () => boolean;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type DomTranslationAttribute = "placeholder" | "title" | "aria-label" | "alt";
|
|
2
|
+
export interface DomTranslationRule {
|
|
3
|
+
readonly source: string;
|
|
4
|
+
readonly target: string;
|
|
5
|
+
readonly scope: string;
|
|
6
|
+
readonly mode?: "exact";
|
|
7
|
+
readonly attributes?: readonly DomTranslationAttribute[];
|
|
8
|
+
}
|
|
9
|
+
export interface TranslationPack {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly target: {
|
|
12
|
+
readonly package: string;
|
|
13
|
+
readonly versions?: string;
|
|
14
|
+
};
|
|
15
|
+
readonly en: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
16
|
+
readonly dom?: readonly DomTranslationRule[];
|
|
17
|
+
readonly metadata?: {
|
|
18
|
+
readonly sourceLanguage?: string;
|
|
19
|
+
readonly description?: string;
|
|
20
|
+
readonly upstream?: string;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export type DiagnosticLevel = "info" | "warning" | "error" | "debug";
|
|
24
|
+
export interface DiagnosticEntry {
|
|
25
|
+
readonly level: DiagnosticLevel;
|
|
26
|
+
readonly code: string;
|
|
27
|
+
readonly message: string;
|
|
28
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@yadsh/dsh-l10n-overrides",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "English localization overrides for DeepSeek Harness plugins",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/xarleyn/dsh-plugins.git",
|
|
8
|
+
"directory": "plugins/dsh-l10n-overrides"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/xarleyn/dsh-plugins/tree/main/plugins/dsh-l10n-overrides#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/xarleyn/dsh-plugins/issues"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"main": "./lib/index.js",
|
|
16
|
+
"types": "./lib/types/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./lib/types/index.d.ts",
|
|
20
|
+
"default": "./lib/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./client": {
|
|
23
|
+
"types": "./lib/types/client/index.d.ts",
|
|
24
|
+
"default": "./lib/client.js"
|
|
25
|
+
},
|
|
26
|
+
"./types": {
|
|
27
|
+
"types": "./lib/types/types.d.ts"
|
|
28
|
+
},
|
|
29
|
+
"./package.json": "./package.json"
|
|
30
|
+
},
|
|
31
|
+
"dsh": {
|
|
32
|
+
"bundle": {
|
|
33
|
+
"patch": "./cordis.patch.yml"
|
|
34
|
+
},
|
|
35
|
+
"client": {
|
|
36
|
+
"platform": "web",
|
|
37
|
+
"inject": [
|
|
38
|
+
"@deepseek-ai/dsh-client-locale"
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"files": [
|
|
43
|
+
"lib/**/*.js",
|
|
44
|
+
"lib/types/**/*.d.ts",
|
|
45
|
+
"cordis.patch.yml",
|
|
46
|
+
"README.md",
|
|
47
|
+
"ROADMAP.md",
|
|
48
|
+
"LICENSE"
|
|
49
|
+
],
|
|
50
|
+
"scripts": {
|
|
51
|
+
"clean": "node -e \"require('node:fs').rmSync('lib', { recursive: true, force: true })\"",
|
|
52
|
+
"lint": "eslint src tests scripts",
|
|
53
|
+
"format": "prettier --check . --end-of-line auto",
|
|
54
|
+
"format:write": "prettier --write . --end-of-line auto",
|
|
55
|
+
"typecheck": "tsc --noEmit",
|
|
56
|
+
"test": "vitest run",
|
|
57
|
+
"build": "pnpm run clean && tsdown && tsc -p tsconfig.build.json",
|
|
58
|
+
"test:package": "node scripts/verify-package.mjs && node scripts/verify-client-bundle.mjs",
|
|
59
|
+
"verify": "pnpm run test:package",
|
|
60
|
+
"check": "pnpm run format && pnpm run typecheck && pnpm run test && pnpm run build && pnpm run test:package",
|
|
61
|
+
"prepare": "tsdown && tsc -p tsconfig.build.json",
|
|
62
|
+
"prepublishOnly": "pnpm run check"
|
|
63
|
+
},
|
|
64
|
+
"keywords": [
|
|
65
|
+
"deepseek",
|
|
66
|
+
"deepseek-harness",
|
|
67
|
+
"dsh",
|
|
68
|
+
"dsh-plugin",
|
|
69
|
+
"localization",
|
|
70
|
+
"web-ui"
|
|
71
|
+
],
|
|
72
|
+
"license": "MIT",
|
|
73
|
+
"engines": {
|
|
74
|
+
"node": "^22.19.0 || >=24.0.0"
|
|
75
|
+
},
|
|
76
|
+
"peerDependencies": {
|
|
77
|
+
"@deepseek-ai/cordis": "catalog:dsh",
|
|
78
|
+
"@deepseek-ai/dsh-client-locale": "catalog:dsh"
|
|
79
|
+
},
|
|
80
|
+
"devDependencies": {
|
|
81
|
+
"@deepseek-ai/cordis": "catalog:dsh-dev",
|
|
82
|
+
"@deepseek-ai/dsh-client-locale": "catalog:dsh-dev",
|
|
83
|
+
"@types/node": "catalog:tooling",
|
|
84
|
+
"eslint": "catalog:tooling",
|
|
85
|
+
"jsdom": "^26.1.0",
|
|
86
|
+
"prettier": "catalog:tooling",
|
|
87
|
+
"tsdown": "catalog:tooling",
|
|
88
|
+
"typescript": "catalog:plugin-tooling",
|
|
89
|
+
"vitest": "catalog:tooling"
|
|
90
|
+
},
|
|
91
|
+
"publishConfig": {
|
|
92
|
+
"access": "public",
|
|
93
|
+
"registry": "https://registry.npmjs.org/"
|
|
94
|
+
}
|
|
95
|
+
}
|