i18n-ai-translate
Version:
AI-powered localization CLI, Node library, and GitHub Action. Translate i18next JSON, Gettext PO, Java .properties, and iOS .strings with ChatGPT, Claude, Gemini, or local Ollama models.
19 lines (18 loc) • 866 B
TypeScript
import type { ChatParams } from "../types";
import type { ZodType, ZodTypeDef } from "zod";
export type InvalidKind = "translation" | "styling";
export default abstract class ChatInterface {
abstract startChat(params: ChatParams): void;
abstract sendMessage(message: string, format?: ZodType<any, ZodTypeDef, any>): Promise<string>;
abstract resetChatHistory(): void;
abstract rollbackLastMessage(): void;
/**
* Record that the last translation was rejected, so the next
* sendMessage call picks up the nag message in history.
* Implementations choose whether to tag that message as System or
* User — Anthropic, for example, only accepts alternating User /
* Assistant messages, so it reuses User.
*/
abstract signalInvalid(kind: InvalidKind): void;
protected invalidMessage(kind: InvalidKind): string;
}