/** * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options */ /** * @module ai/aitranslate/aitranslate * @publicApi */ import { ContextPlugin, type PluginDependenciesOf } from "@ckeditor/ckeditor5-core"; import { AITranslateController } from "./aitranslatecontroller.js"; import { AITranslateUI } from "./aitranslateui.js"; import { AITranslateGateway } from "./aitranslategateway.js"; import { AIReviewCoreEditing } from "../aireviewcore/aireviewcoreediting.js"; /** * The AI Translate feature. * * The Translate feature provides users with AI-powered translation for their content by automatically translating text * into different languages. * * You can configure the feature by setting the {@link module:ai/aitranslate/aitranslate~AITranslateConfig} property. * * Learn more about AI features in CKEditor in the {@glink features/ai/ckeditor-ai-overview AI Overview} documentation. */ export declare class AITranslate extends ContextPlugin { /** * @inheritDoc */ static get requires(): PluginDependenciesOf<[AITranslateController, AITranslateUI, AIReviewCoreEditing, AITranslateGateway]>; /** * @inheritDoc */ static get pluginName(): "AITranslate"; /** * @inheritDoc */ static override get isOfficialPlugin(): true; /** * @inheritDoc */ static override get isPremiumPlugin(): true; /** * Launches a translation on the UI — the programmatic equivalent of clicking a language in the Translate panel. * * If the AI tabs component is hidden or the Translate tab is not active, it is shown and activated first. * * Preconditions: * - The `languageId` must point at a language available in the UI, that is one of the languages configured via * {@link module:ai/aitranslate/aitranslate~AITranslateConfig#languages `ai.translate.languages`} (or the default * list when the option is not set). Unknown ids throw `ai-translate-unknown-language`. * Use {@link #getAvailableLanguages} for valid language ids. * - No other translation can be running. Otherwise the method throws `ai-translate-translation-already-running`. * * The returned promise resolves once the translation run is dispatched to the controller. The translation itself * continues to run asynchronously and the UI reflects its progress. Stream-phase failures surface via the existing * UI error views, not via this promise. * * @experimental **Experimental:** This is a production-ready API but may change in minor releases * without the standard deprecation policy. Check the changelog for migration guidance. * @param languageId Id of a language returned by {@link #getAvailableLanguages}. */ startTranslate(languageId: string): Promise; /** * Returns the list of languages that content can be translated into via {@link #startTranslate} and are available * in the AI Translate UI. * * The list reflects the {@link module:ai/aitranslate/aitranslate~AITranslateConfig#languages `ai.translate.languages`} * configuration (or the default list when the option is not set), with labels translated to the editor UI language. * * @experimental **Experimental:** This is a production-ready API but may change in minor releases * without the standard deprecation policy. Check the changelog for migration guidance. */ getAvailableLanguages(): Array; } /** * The configuration of the {@link module:ai/aitranslate/aitranslate~AITranslate AI Translate feature}. * * The properties defined in this config are set in the `config.ai.translate` namespace. * * ```ts * ClassicEditor * .create( { * ai: { * translate: { * // AI Translate configuration. * } * } * } ) * .then( ... ) * .catch( ... ); * ``` * * See {@link module:ai/aiconfig~AIConfig the full AI configuration}. * * See {@link module:core/editor/editorconfig~EditorConfig all editor options}. */ export interface AITranslateConfig { /** * The list of languages available in the AI Translate feature. * * The list must be an array of objects containing the `id` and `label` properties like on example below: * * ```ts * ClassicEditor * .create( { * ai: { * translate: { * languages: [ * { * id: 'german', * label: 'German' * }, * { * id: 'french', * label: 'French' * } * ] * } * } * } ) * .then( ... ) * .catch( ... ); * ``` * * Languages available by default are: * * { * label: 'English', * id: 'english' * }, * { * label: 'Spanish', * id: 'spanish' * }, * { * label: 'French', * id: 'french' * }, * { * label: 'German', * id: 'german' * }, * { * label: 'Chinese (Simplified)', * id: 'chinese' * }, * { * label: 'Japanese', * id: 'japanese' * }, * { * label: 'Russian', * id: 'russian' * }, * { * label: 'Portuguese', * id: 'portuguese' * }, * { * label: 'Korean', * id: 'korean' * }, * { * label: 'Italian', * id: 'italian' * } */ languages?: Array; } export interface AITranslateLanguage { id: string; label: string; }