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.
33 lines (32 loc) • 1.15 kB
TypeScript
import type { GetTextComment, GetTextTranslations } from "gettext-parser";
import type FormatAdapter from "./format_adapter";
type PlaceholderMap = {
/** Ordered list of native tokens, one per arg slot. */
tokens: string[];
/** Whether the entry used positional (`%1$s`) or bare (`%s`) tokens. */
positional: boolean;
};
type POEntryMeta = {
msgctxt?: string;
msgid: string;
isPlural: boolean;
/** Original comments; preserved on write. */
comments?: GetTextComment;
placeholders?: PlaceholderMap;
};
/**
* Everything we need to reconstruct the PO file after the flat map
* round-trips through the pipeline. The parsed table is kept so header
* fields, ordering, obsolete entries, and unreferenced comments all
* survive a write.
*/
type POSidecar = {
kind: "po";
parsed: GetTextTranslations;
/** Keyed by the same flat key used by the pipeline. */
metaByKey: Record<string, POEntryMeta>;
/** Source language's plural category list, captured at read time. */
sourceCategories: readonly string[];
};
declare const POAdapter: FormatAdapter<POSidecar>;
export default POAdapter;