UNPKG

wuchale

Version:

Protobuf-like i18n from plain code

31 lines (30 loc) 848 B
import PO from 'pofile'; import { type Logger } from '../log.js'; export type ItemType = InstanceType<typeof PO.Item>; type Batch = { id: number; messages: ItemType[]; }; export type AI = { name: string; batchSize: number; translate: (messages: string, instruction: string) => Promise<string>; parallel: number; }; export default class AIQueue { #private; batches: Batch[]; nextBatchId: number; running: Promise<void> | null; sourceLang: string; targetLang: string; ai: AI; instruction: string; onComplete: () => Promise<void>; log: Logger; constructor(sourceLang: string, targetLang: string, ai: AI, onComplete: () => Promise<void>, log: Logger); translate: (batch: Batch) => Promise<void>; run: () => Promise<void>; add: (messages: ItemType[]) => void; } export {};