Skip to content

导出 INI

按导出模板(template_id)同步生成 INI 文件,上传到对象存储后返回 1 小时有效的下载签名 URL。

当前仅支持 type="project_strings"task_strings 因导出 filter 复杂(按 source/target 语言对过滤)暂不通过开放平台暴露 —— 后续版本会补上。

请求地址

POST {BASE_URL}/api/open/v1/export/ini

鉴权 Header

创建翻译任务 完全一样。POST 的 raw body 参与签名:MD5(timestamp + raw_body + appSecret)

请求体(JSON)

json
{
  "type": "project_strings",
  "template_id": "tpl-9d3f1a2c",
  "target_languages": ["en", "ja"],
  "download_mode": "single",
  "escape_mode": "no-escape",
  "filename": "v1.0_en_ja"
}

字段说明

字段类型必填说明
typestring当前仅支持 project_strings(项目字符串 / 全文本)
template_idstring模板 ID。模板必须满足 format=ini(可在 创建模板 时设置)
target_languagesstring[]覆盖模板的 languages;为空则用模板自身的 languages,且模板的 languages 也为空时 422
download_modestring覆盖模板的 modesingle(多语言一个 INI)/ separate(每语言一个 INI 打 ZIP)。默认沿用模板,模板未设则 single
escape_modestring覆盖项目设置 export_settings.ini_escape_modeescape(转义 \n / \r / \t / \\)/ no-escape(原样输出)。默认沿用项目设置,项目未设则 no-escape
filenamestring导出文件名前缀(自动加 .ini.ini.zip 扩展名);为空时用 {projectId}_{timestamp}

响应

json
{
  "success": true,
  "code": 0,
  "msg": "ok",
  "trace_id": "...",
  "data": {
    "download_url": "https://storage.googleapis.com/loxily-export/...&Signature=...",
    "expires_at": "2026-05-12T13:00:00.000Z",
    "file_size": 12345,
    "format": "ini",
    "download_mode": "single",
    "target_languages": ["en", "ja"],
    "escape_mode": "no-escape"
  }
}
字段类型说明
download_urlstringGCS v4 签名 URL,浏览器/客户端可直接下载,有效期 1 小时
expires_atstring签名过期时间(ISO 8601)
file_sizeint文件大小(字节)
formatstring固定 ini
download_modestring实际生效的模式(single / separate
target_languagesstring[]实际导出的语言
escape_modestring实际生效的转义模式

行为说明

  • 范围:固定 scope=all(项目下所有 string)。开放接口不支持页面端的"按当前过滤视图导出"。
  • 空值过滤:每条记录里 target_lang 为空 / null 的语言不会写进 INI;string_id 为空的整行跳过。
  • 数据量:典型项目 1k–10k 条 string,多语言 separate 模式打 ZIP 大约几十毫秒到几秒。接口超时 5 分钟,超大数据量请分多次(按语言子集)调用。
  • 下载 URL:返回后请尽快下载(1 小时过期);如需再下载,重新调用本接口即可(每次返回新签名 URL)。

错误码

code说明
400请求体不是合法 JSON / template_id 缺失 / download_mode / escape_mode / target_languages / filename 类型或值非法
401签名校验失败 / 时间戳过期
403App Secret 未配置
404template_id 对应的模板不存在
422type 不是 project_strings / 模板的 format 不是 ini / 合并模板后 languages 仍为空
500导出执行失败 / GCS 上传失败

示例

bash
APP_KEY="5685414646a54423c891d87194d87f3f"
APP_SECRET="<你的 App Secret>"
BASE_URL="https://api.loxily.com"

BODY='{"type":"project_strings","template_id":"tpl-9d3f1a2c","target_languages":["en","ja"],"download_mode":"single"}'
TIMESTAMP=$(date +%s)
SIGN=$(printf '%s' "${TIMESTAMP}${BODY}${APP_SECRET}" | md5)

# 1) 调接口拿签名 URL
RESP=$(curl -s -X POST "${BASE_URL}/api/open/v1/export/ini" \
  -H "Content-Type: application/json" \
  -H "X-Loxily-AppKey: ${APP_KEY}" \
  -H "X-Loxily-Timestamp: ${TIMESTAMP}" \
  -H "X-Loxily-Sign: ${SIGN}" \
  --data "${BODY}")

echo "$RESP"

# 2) 用 jq 提取 download_url 直接下载
URL=$(echo "$RESP" | jq -r '.data.download_url')
curl -L -o export.ini "$URL"