插件:多语言-获取商品翻译数据
一次性获取商品的全部翻译数据,是商品多语言编辑的入口 API。后续按三个部分分别保存:主体、Option、Item。
接口信息
- 接口地址:
{your-site-url}/api/skill/addons-language/get-product-translate - 基础 URL:
{your-site-url}需替换为你自己的独立站 URL 地址,如https://your-domain.com/apimanager666 - 请求方式:
GET 说明: 一次性获取商品的全部翻译数据,作为多语言编辑的起点。返回数据分为三组,对应三个保存接口:
| 数据组 | 获取字段 | 保存接口 | |--------|---------|---------| | 商品主体 |
product_data+product_translate| 插件:多语言-保存商品翻译(主体) | | 变体 Option |product_options_data+product_options_translate| 插件:多语言-保存商品变体Option翻译 | | 变体 Item |product_option_items_data+product_option_items_translate| 插件:多语言-保存商品变体item翻译 |编辑流程:
- 插件:多语言-翻译语言列表 获取翻译语言
- 本接口获取全部翻译数据
- 比对各语言下的默认数据和已翻译数据,找出缺失翻译的字段并补齐
- 分别调用三个保存接口提交
认证
请求头中需要携带 skill-access-token:
| Header | 值 |
|---|---|
skill-access-token |
{your-skill-access-token} (请替换为你自己的 token) |
请求参数 (Query)
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
product_id |
int | 是 | 商品 ID |
请求示例
cURL
curl --location --request GET '{your-site-url}/api/skill/addons-language/get-product-translate?product_id=7041' \
--header 'skill-access-token: {your-skill-access-token}'
返回结果
code 为 200 表示调用成功;code 不为 200 表示调用失败。
成功响应
{
"code": 200,
"data": {
"product_data": {
"title": "Denim Jacket Shirt",
"sub_title": "",
"body_html": "<div>...</div>",
"meta_title": "Denim Jacket Shirt",
"meta_keywords": "",
"meta_description": "",
"feed_title": "",
"feed_description": null
},
"product_translate": [
{
"id": 2872,
"lang_code": "cn",
"title": "牛仔衬衫外套",
"sub_title": "",
"body_html": "<div>...</div>",
"meta_title": "牛仔衬衫外套",
"meta_keywords": "",
"meta_description": "",
"feed_title": "",
"feed_description": "",
"created_at": "2026-06-08 19:09:43",
"updated_at": "2026-06-08 19:09:43"
}
],
"product_options_data": ["Color", "Size"],
"product_option_items_data": ["Blue", "Black", "Pink", "M", "L", "XL", "XXL"],
"product_options_translate": {
"cn": {
"lang_code": "cn",
"translate": {
"Size": "尺码",
"Color": "颜色"
}
},
"ja": {
"lang_code": "ja",
"translate": {
"Size": "サイズ",
"Color": "カラー"
}
}
},
"product_option_items_translate": {
"cn": {
"lang_code": "cn",
"translate": {
"Blue": "蓝色",
"Black": "黑色",
"Pink": "粉色",
"M": "M",
"L": "L"
}
},
"ja": {
"lang_code": "ja",
"translate": {
"Blue": "ブルー",
"Black": "ブラック",
"M": "M",
"L": "L"
}
}
}
},
"message": "success"
}
返回字段说明
| 字段 | 类型 | 说明 |
|---|---|---|
code |
Number | 状态码,200 表示成功 |
message |
String | 执行结果的文字描述 |
data |
Object | 商品翻译数据 |
1. product_data — 商品主体默认数据
| 字段 | 类型 | 说明 |
|---|---|---|
title |
string | 商品标题 |
sub_title |
string | 商品副标题 |
body_html |
string | 商品描述(HTML 格式) |
meta_title |
string | SEO 标题 |
meta_keywords |
string | SEO 关键词 |
meta_description |
string | SEO 描述 |
feed_title |
string | Feed 商品标题 |
feed_description |
string | Feed 商品描述 |
2. product_translate — 商品主体各语言翻译
| 字段 | 类型 | 说明 |
|---|---|---|
lang_code |
string | 语言简码。与 插件:多语言-翻译语言列表 的 code 对应 |
title |
string | 翻译后标题 |
sub_title |
string | 翻译后副标题 |
body_html |
string | 翻译后描述(HTML 格式) |
meta_title |
string | 翻译后 SEO 标题 |
meta_keywords |
string | 翻译后 SEO 关键词 |
meta_description |
string | 翻译后 SEO 描述 |
feed_title |
string | 翻译后 Feed 标题 |
feed_description |
string | 翻译后 Feed 描述 |
created_at |
string | 创建时间 |
updated_at |
string | 最后更新时间 |
3. product_options_data — 变体 Option 默认数据
Array[string],商品变体的规格名称列表。如 ["Color", "Size"],表示该商品有"颜色"和"尺码"两个规格。
4. product_options_translate — 变体 Option 各语言翻译
Object,key 为语言简码,value 含 lang_code + translate。translate 为对象,key = Option 原始值,value = 翻译值。
如 "cn" → translate → {"Size": "尺码", "Color": "颜色"},表示中文下 Size 翻译为"尺码"、Color 翻译为"颜色"。
5. product_option_items_data — 变体 Item 默认数据
Array[string],商品变体的规格值列表。如 ["Blue", "Black", "M", "L", "XL"],包含所有规格下的值。
6. product_option_items_translate — 变体 Item 各语言翻译
Object,key 为语言简码,value 含 lang_code + translate。translate 为对象,key = Item 原始值,value = 翻译值。
如 "cn" → translate → {"Blue": "蓝色", "Black": "黑色"},表示中文下 Blue 翻译为"蓝色"。
涉及的翻译字段总结
| 分类 | 可翻译字段 | 数量 |
|---|---|---|
| 商品主体 | title, sub_title, body_html, meta_title, meta_keywords, meta_description, feed_title, feed_description | 8 |
| 变体 Option | translate 对象中的 key 为 Option 值 | 动态 |
| 变体 Item | translate 对象中的 key 为 Item 值 | 动态 |
注意事项
- 本接口是商品多语言编辑的入口,一次获取全部数据
- 对比
product_data和product_translate:遍历各语言,找出product_translate中缺失或为空的字段进行翻译 - 对比
product_options_data和product_options_translate:遍历各语言下translate对象,找出缺失或为空的 Option key - 对比
product_option_items_data和product_option_items_translate:遍历各语言下translate对象,找出缺失或为空的 Item key - 翻译完成后分别调用三个保存接口提交