Skip to main content
All docs
V25.2
  • IAIDocProcessingService.TranslateAsync(Slide, CultureInfo, CancellationToken) Method

    Translates slide content into a specific language with AI-powered translation services.

    Namespace: DevExpress.AIIntegration.Docs

    Assembly: DevExpress.AIIntegration.Docs.v25.2.dll

    NuGet Package: DevExpress.AIIntegration.Docs

    Declaration

    Task TranslateAsync(
        Slide slide,
        CultureInfo culture,
        CancellationToken cancellationToken = default(CancellationToken)
    )

    Parameters

    Name Type Description
    slide Slide

    The Slide instance which content should be translated.

    culture CultureInfo

    An object that specifies culture settings applied during translation.

    Optional Parameters

    Name Type Default Description
    cancellationToken CancellationToken null

    The token that cancels the task.

    Returns

    Type Description
    Task

    The response that contains AI-generated translation.’

    Example

    How to: Translate the First Slide in the Presentation

    The following code snippet translates the first slide in a presentation:

    using DevExpress.AIIntegration;
    using DevExpress.AIIntegration.Docs;
    using DevExpress.Docs.Presentation;
    using Microsoft.Extensions.AI;
    
    // See "Register AI extension service" section for implementation code
    docProcessingService docProcessingService = 
            defaultAIExtensionsContainer.CreateAIDocProcessingService();
    
    var presentation = 
            new Presentation(File.ReadAllBytes("Documents/Presentation.pptx"));
    
    await docProcessingService.TranslateAsync(
            presentation.Slides[0], 
            new System.Globalization.CultureInfo("DE-DE"));
    
    // Save the modified document
    FileStream outputStream = File.OpenWrite(
            Path.Combine(
                    Path.Combine(
                            Environment.CurrentDirectory, 
                            $"presentation_translated.pptx")));
    presentation.SaveDocument(outputStream, DocumentFormat.Pptx);
    outputStream.Close();
    
    See Also