fix: worker use only i18n keys instead of full i18n

This commit is contained in:
2026-09-13 12:44:51 +05:00
parent 49d0a9444e
commit c2f3838485
12 changed files with 111 additions and 38 deletions
+1 -2
View File
@@ -8,7 +8,6 @@ import {
renderPredicateMask,
} from "../core/masks";
import { base64ToBytes, looksLikePng, stripDataUri } from "../core/textio";
import { t } from "../i18n/t";
import { field, toolSchema } from "../registry-schema";
import { imgTool, textGen, type ToolEntry } from "./types";
@@ -277,7 +276,7 @@ const pngFileSize: ToolEntry<NoParams> = {
const blob = await encode(img, "image/png");
const kb = blob.size / 1024;
const kbText = kb >= 100 ? Math.round(kb).toString() : kb.toFixed(1);
return t("tools.png-file-size.results.line", { kb: kbText });
return { key: "line", vars: { kb: kbText } };
}),
};
+9 -8
View File
@@ -1,30 +1,31 @@
import type { ToolEntry } from "./types";
import { geometryEntries } from "./geometry";
import { alphaEntries } from "./alpha";
import { convertEntries } from "./convert";
import { analyzeEntries } from "./analyze";
import { filtersEntries } from "./filters";
import { colorEntries } from "./color";
import { convertEntries } from "./convert";
import { filtersEntries } from "./filters";
import { generateEntries } from "./generate";
import { geometryEntries } from "./geometry";
import { textEntries } from "./text";
import type { ToolEntry } from "./types";
export {
genTool,
imgTool,
textGen,
INPUT_MODES,
requireSource,
requireText,
INPUT_MODES,
RESULT_KINDS,
textGen,
} from "./types";
export type {
FileResult,
InputMode,
ResultKind,
ToolContext,
ToolEntry,
ToolResult,
ToolImageFile,
FileResult,
ToolResult,
VerdictResult,
} from "./types";
export const TOOLS: ToolEntry[] = [
+12 -1
View File
@@ -49,7 +49,18 @@ export interface FileResult {
files: ToolImageFile[];
}
export type ToolResult = PixelImage | string | FileResult;
/**
* Вердикт с подстановками: `key` — ключ словаря (`tools[id].results[key]`),
* `vars` — значения для интерполяции `{name}`. Локализация выполняется на
* стороне UI; из run() (и тем более из worker) локализованные строки не
* возвращаются.
*/
export interface VerdictResult {
key: string;
vars?: Record<string, string | number>;
}
export type ToolResult = PixelImage | string | FileResult | VerdictResult;
/**
* Инструмент нового registry: полностью типизирован на `Params`, схема —