You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

DeepL API文档翻译:英文目标语言设置与正式度报错问题

问题

调用DeepL API的TranslateDocumentAsync接口翻译土耳其语(TR)文档至英文时,遇到两个问题:

  • 使用目标语言代码"EN"时触发错误;
  • 改用"EN-GB"后,收到「给定目标语言不支持正式度设置」的报错。
    需要找到能成功翻译英文且支持正式度设置的目标语言代码。
解决方案

DeepL的文档翻译接口中,**美式英语代码"EN-US"**支持正式度(Formality)设置,而通用英文代码"EN"、英式英语代码"EN-GB"在文档翻译场景下不支持该配置。

修正后的代码示例如下:

try
{
    await translator.TranslateDocumentAsync(
          new FileInfo("deneemq11.docx"),
          new FileInfo("deneemq11(11).docx"),
          "TR",
          "EN-US",
          new DocumentTranslateOptions { Formality = Formality.More });
}
catch (DocumentTranslationException exception)
{
    // If the error occurs *after* upload, the DocumentHandle will contain the document ID and key
    if (exception.DocumentHandle != null)
    {
        var handle = exception.DocumentHandle.Value;
        MessageBox.Show($"Document ID: {handle.DocumentId}, Document key: {handle.DocumentKey}");
    }
    else
    {
        MessageBox.Show($"Error occurred during document upload: {exception.Message}");
    }
}

内容的提问来源于stack exchange,提问作者Yakup Aktepe

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 07:57:38