> ## Documentation Index
> Fetch the complete documentation index at: https://docs-docflow.textin.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 翻译文件抽取结果

> 语言使用 ISO 639-1 编码，中文按地区区分为`zh-CN`和`zh-TW`。
`source_language`省略或传空字符串时自动检测源语言；指定源语言时不能与`target_language`相同。
调用接口后执行翻译并同步开启前端详情展示。并发请求会返回“任务正在翻译中，请稍后重试”。

常见业务错误码：
- `1005025065`：任务识别失败，无法执行翻译
- `1005025066`：任务尚未完成识别
- `1005025067`：任务正在翻译中
- `1005025068`：翻译源语言和目标语言相同
- `1005025069`：目标语言为空或不是具体语言编码




## OpenAPI

````yaml /docflow/cn/rest-api/openapi.bundle.yaml post /api/app-api/sip/platform/v2/file/translate
openapi: 3.0.0
info:
  title: DocFlow API
  description: DocFlow REST API，提供文件上传和获取文件处理结果能力
  version: 2.14.1
servers:
  - url: https://docflow.textin.com
security:
  - ApiId: []
    SecretCode: []
paths:
  /api/app-api/sip/platform/v2/file/translate:
    post:
      summary: 翻译文件抽取结果
      description: |
        语言使用 ISO 639-1 编码，中文按地区区分为`zh-CN`和`zh-TW`。
        `source_language`省略或传空字符串时自动检测源语言；指定源语言时不能与`target_language`相同。
        调用接口后执行翻译并同步开启前端详情展示。并发请求会返回“任务正在翻译中，请稍后重试”。

        常见业务错误码：
        - `1005025065`：任务识别失败，无法执行翻译
        - `1005025066`：任务尚未完成识别
        - `1005025067`：任务正在翻译中
        - `1005025068`：翻译源语言和目标语言相同
        - `1005025069`：目标语言为空或不是具体语言编码
      operationId: translateFile
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FileTranslateRequest'
            example:
              task_id: '202412190001'
              source_language: ''
              target_language: zh-CN
      responses:
        '200':
          description: 翻译请求处理完成；具体结果以响应中的业务code为准
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/CodeMessage'
                  - $ref: '#/components/schemas/FileTranslateResult'
components:
  schemas:
    FileTranslateRequest:
      type: object
      required:
        - task_id
        - target_language
      properties:
        task_id:
          type: string
          description: 已完成识别的任务ID。雪花ID必须作为字符串传递，禁止转换为JavaScript Number。
          example: '1978297791713619968'
        source_language:
          $ref: '#/components/schemas/TranslateSourceLanguage'
        target_language:
          $ref: '#/components/schemas/TranslateTargetLanguage'
    CodeMessage:
      type: object
      properties:
        code:
          type: integer
          description: 状态码
          example: 200
        msg:
          type: string
          description: 状态描述
      required:
        - code
        - msg
    FileTranslateResult:
      type: object
      properties:
        result:
          type: object
          required:
            - fields
            - tables
            - stamps
            - handwritings
          properties:
            fields:
              type: array
              description: 普通字段翻译结果
              items:
                $ref: '#/components/schemas/CommonFieldTranslate'
            tables:
              type: array
              description: 表格翻译结果
              items:
                $ref: '#/components/schemas/TableDetailTranslate'
            stamps:
              type: array
              description: 印章翻译结果
              items:
                $ref: '#/components/schemas/StampTranslateResult'
            handwritings:
              type: array
              description: 手写体翻译结果
              items:
                $ref: '#/components/schemas/HandwritingTranslateResult'
    TranslateSourceLanguage:
      type: string
      description: 翻译源语言，使用 ISO 639-1 编码；省略或空字符串均表示自动检测。
      enum:
        - ''
        - zh-CN
        - zh-TW
        - ja
        - ko
        - en
        - fr
        - pt
        - de
        - it
        - es
        - ru
        - th
        - vi
        - ms
        - id
        - hi
        - bn
        - ar
        - pl
      example: ''
    TranslateTargetLanguage:
      type: string
      description: 翻译目标语言，使用 ISO 639-1 编码，必填且必须是具体语言。
      enum:
        - zh-CN
        - zh-TW
        - ja
        - ko
        - en
        - fr
        - pt
        - de
        - it
        - es
        - ru
        - th
        - vi
        - ms
        - id
        - hi
        - bn
        - ar
        - pl
      example: zh-CN
    CommonFieldTranslate:
      type: object
      properties:
        key:
          type: string
          description: 原字段key
          example: invoiceNumber
        translated_key:
          type: string
          nullable: true
          description: 字段key翻译结果；表格单元格通常不使用
        index:
          type: integer
          description: 同名字段索引，从0开始
          example: 0
        value:
          type: string
          nullable: true
          description: 字段值翻译结果
    TableDetailTranslate:
      type: object
      properties:
        table_name:
          type: string
          description: 原表格名称
        translated_table_name:
          type: string
          nullable: true
          description: 表格名称翻译结果
        items:
          type: array
          description: 表格数据翻译结果，外层为行、内层为单元格
          items:
            type: array
            items:
              $ref: '#/components/schemas/CommonFieldTranslate'
        item_headers:
          type: array
          description: 表头翻译结果
          items:
            $ref: '#/components/schemas/TableFieldHeadTranslate'
    StampTranslateResult:
      type: object
      properties:
        key:
          type: string
          description: 印章唯一标识，格式为stamp-${page}-${index}
        page:
          type: integer
          description: 页码
        index:
          type: integer
          description: 页内序号，从0开始
        stamp_prefix:
          type: string
          nullable: true
          description: 印章前缀翻译结果
        type_key:
          type: string
          nullable: true
          description: 印章类型key翻译结果
        type:
          type: string
          nullable: true
          description: 印章类型翻译结果
        color_key:
          type: string
          nullable: true
          description: 印章颜色key翻译结果
        color:
          type: string
          nullable: true
          description: 印章颜色翻译结果
        stamp_shape_key:
          type: string
          nullable: true
          description: 印章形状key翻译结果
        stamp_shape:
          type: string
          nullable: true
          description: 印章形状翻译结果
        value_key:
          type: string
          nullable: true
          description: 印章文字key翻译结果
        value:
          type: string
          nullable: true
          description: 印章文字翻译结果
    HandwritingTranslateResult:
      type: object
      properties:
        key:
          type: string
          description: 手写体唯一标识，格式为handwriting-${page}-${lineIndex}
        page:
          type: integer
          description: 页码
        index:
          type: integer
          description: 页内序号，从0开始
        handwriting_prefix:
          type: string
          nullable: true
          description: 手写体前缀翻译结果
        text:
          type: string
          nullable: true
          description: 手写体文字翻译结果
    TableFieldHeadTranslate:
      type: object
      properties:
        key:
          type: string
          description: 原表头key
        translated_key:
          type: string
          nullable: true
          description: 表头key翻译结果
  securitySchemes:
    ApiId:
      type: apiKey
      in: header
      name: x-ti-app-id
    SecretCode:
      type: apiKey
      in: header
      name: x-ti-secret-code

````