/** * @license * Copyright 2026 aphrody-code * SPDX-License-Identifier: Apache-2.0 */ /** * Official Google Cloud Translation API v2 request parameters. */ export interface TranslateV2Request { /** The input text to translate. Repeat this parameter to translate multiple strings. */ q: string | string[]; /** The language to use for translation of the input text, set to one of the language codes. */ target: string; /** The language of the source text, set to one of the language codes. If empty, the service will attempt to auto-detect. */ source?: string; /** The format of the source text, in either "text" (default) or "html". */ format?: "text" | "html"; /** The translation model: "base" or "nmt". */ model?: "base" | "nmt" | string; } /** * Official Google Cloud Translation API v2 translation item. */ export interface TranslationV2Item { /** Text translated into the target language. */ translatedText: string; /** The source language of the initial request, detected automatically if not provided. */ detectedSourceLanguage?: string; /** The translation model. */ model?: string; } /** * Official Google Cloud Translation API v2 response shape. */ export interface TranslateV2Response { data: { translations: TranslationV2Item[]; }; } /** * Official Google Cloud Translation API v2 detect language request. */ export interface DetectLanguageV2Request { q: string | string[]; } /** * Detection result item. */ export interface DetectionV2Item { language: string; confidence: number; isReliable: boolean; } /** * Official Google Cloud Translation API v2 detect response shape. */ export interface DetectLanguageV2Response { data: { detections: DetectionV2Item[][]; }; } /** * Supported language item. */ export interface SupportedLanguageItem { language: string; name?: string; } /** * Official Google Cloud Translation API v2 languages response shape. */ export interface SupportedLanguagesV2Response { data: { languages: SupportedLanguageItem[]; }; } /** * Engine execution options. */ export interface TranslateEngineOptions { /** Strategy preference: "auto" | "rpc" | "web" | "gemini" | "gcloud" */ strategy?: "auto" | "rpc" | "web" | "gemini" | "gcloud"; /** Disable caching */ noCache?: boolean; /** Custom timeout in ms */ timeoutMs?: number; /** Concurrency limit for batch arrays */ concurrency?: number; /** Fetch rich details (pronunciation, dictionary, definitions, spell correction) */ detailed?: boolean; } /** * Detailed term entry in bilingual dictionary. */ export interface DictionaryTermDetail { word: string; reverseTranslations: string[]; score?: number; article?: string; } /** * Bilingual dictionary entry by part of speech. */ export interface DictionaryEntry { partOfSpeech: string; terms: string[]; details: DictionaryTermDetail[]; } /** * Single definition item with optional example. */ export interface DefinitionItem { definition: string; example?: string; label?: string; } /** * Definition entry grouped by part of speech. */ export interface DefinitionEntry { partOfSpeech: string; definitions: DefinitionItem[]; } /** * Auto-correction / Did-you-mean details. */ export interface AutoCorrection { didYouMean: boolean; autoCorrected: boolean; originalText: string; correctedText: string; htmlSnippet?: string; } /** * Detailed translation item including pronunciation, dictionary, and correction. */ export interface DetailedTranslationV2Item extends TranslationV2Item { /** Phonetic transliteration / pronunciation (e.g. Romaji, Pinyin, IPA). */ pronunciation?: string; /** Phonetic transliteration of the source text. */ sourcePronunciation?: string; /** Typo correction or Did-you-mean suggestion. */ correction?: AutoCorrection; /** Full bilingual dictionary entries. */ dictionary?: DictionaryEntry[]; /** Definitions and grammatical notes. */ definitions?: DefinitionEntry[]; /** Alternative translations. */ possibleTranslations?: string[]; /** Raw RPC response array when requested. */ raw?: any; } /** * Detailed translation response shape. */ export interface DetailedTranslateV2Response { data: { translations: DetailedTranslationV2Item[]; }; } /** * Text-to-Speech options. */ export interface TTSOptions { text: string; lang: string; speed?: number; timeoutMs?: number; } /** * Text-to-Speech binary audio result. */ export interface TTSResult { audioBuffer: Uint8Array; mimeType: string; size: number; }