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

# 本地化

> 使用 Accept-Language 标头请求中文和日文的翻译 API 响应。

## 概述

Legitmark 支持分类数据的本地化 API 响应 — 类别、类型、面、服务、阶段和原因。当您设置 `Accept-Language` 标头时，可翻译的字段将以请求的语言而非英语返回。

这对于以用户首选语言显示类别名称、拍照说明和拒绝原因非常有用。

## 支持的语言

| 语言代码 | 语言     | 示例 `Accept-Language`  |
| ---- | ------ | --------------------- |
| `en` | 英语（默认） | `Accept-Language: en` |
| `zh` | 简体中文   | `Accept-Language: zh` |
| `ja` | 日语     | `Accept-Language: ja` |

如果省略标头或包含不支持的语言，API 默认返回英语。

## 使用方法

在返回可翻译数据的任何请求中添加 `Accept-Language` 标头：

<CodeGroup>
  ```javascript HTTP theme={null}
  const response = await fetch('https://api.legitmark.com/api/v2/categories?active_only=true', {
    headers: {
      'Authorization': 'Bearer leo_xxxxxxxxx',
      'Accept-Language': 'zh'
    }
  });
  const { data } = await response.json();
  // data[0].name → "箱包"（而不是 "Bags"）
  ```

  ```typescript SDK theme={null}
  const { data: categories } = await legitmark.taxonomy.getCategories({
    headers: { 'Accept-Language': 'ja' }
  });
  // categories[0].name → "バッグ"
  ```
</CodeGroup>

响应包含 `Content-Language` 标头确认使用的语言：

```
Content-Language: zh
```

## 可翻译的端点

以下端点支持本地化响应：

### 类别

| 端点                                   | 翻译字段          |
| ------------------------------------ | ------------- |
| `GET /api/v2/categories`             | `name`        |
| `GET /api/v2/categories/:uuid`       | `name`        |
| `GET /api/v2/categories/:uuid/types` | `name`（类型）    |
| `GET /api/v2/categories/tree`        | `name`（类别和类型） |

### 类型

| 端点                        | 翻译字段   |
| ------------------------- | ------ |
| `GET /api/v2/types`       | `name` |
| `GET /api/v2/types/:uuid` | `name` |

### 面（拍照要求）

| 端点                                 | 翻译字段                      |
| ---------------------------------- | ------------------------- |
| `GET /api/v2/sides`                | `name`、`description`      |
| `GET /api/v2/sides/:uuid`          | `name`、`description`      |
| `GET /api/v2/sr/:uuid/side-groups` | `name`、`description`（嵌套面） |

<Tip>
  面的翻译对于向用户显示拍照说明特别有用。例如，“正面”及其描述“拍摄物品正面的清晰照片”可以以用户的语言显示。
</Tip>

### 原因（拒绝原因）

| 端点                            | 翻译字段                 |
| ----------------------------- | -------------------- |
| `GET /api/v2/reasons`         | `name`、`description` |
| `GET /api/v2/reasons/:uuid`   | `name`、`description` |
| `GET /api/v2/reasons/grouped` | `name`、`description` |

### 服务

| 端点                        | 翻译字段                 |
| ------------------------- | -------------------- |
| `GET /api/services/:uuid` | `name`、`description` |

### 阶段

| 端点   | 翻译字段                  |
| ---- | --------------------- |
| 阶段端点 | `title`、`description` |

### 服务请求（V2）

| 端点                     | 翻译字段              |
| ---------------------- | ----------------- |
| `GET /api/v2/sr/:uuid` | 嵌入的类别、类型、面和原因均已翻译 |

## 示例：本地化分类体系流程

典型的集成以用户的语言呈现分类体系选择：

```javascript theme={null}
const userLocale = 'zh'; // 来自用户偏好

const headers = {
  'Authorization': 'Bearer leo_xxxxxxxxx',
  'Accept-Language': userLocale
};

// 第 1 步：获取中文类别
const categoriesRes = await fetch(
  'https://api.legitmark.com/api/v2/categories?active_only=true',
  { headers }
);
const { data: categories } = await categoriesRes.json();
// → [{name: "箱包", uuid: "..."}, {name: "手表", uuid: "..."}, ...]

// 第 2 步：获取选定类别的类型（也是中文）
const typesRes = await fetch(
  `https://api.legitmark.com/api/v2/categories/${selectedCategoryUuid}/types`,
  { headers }
);
const { data: types } = await typesRes.json();
// → [{name: "托特包", uuid: "..."}, ...]

// 第 3 步：创建 SR 后，获取本地化说明的面组
const sidesRes = await fetch(
  `https://api.legitmark.com/api/v2/sr/${srUuid}/side-groups`,
  { headers }
);
const { data: sideGroups } = await sidesRes.json();
// 面具有翻译的名称和描述用于拍照指导
```

## 回退行为

* 如果特定字段的翻译不可用，则返回英文值
* 如果语言标头格式错误或不受支持，则使用英语
* 品牌和型号**不会被翻译** — 它们在全球范围内使用原始名称

## 后续步骤

1. **查看** [分类体系](/cn/partner/taxonomy) 了解分类系统
2. **实施** [工作流程](/cn/partner/workflow) 完整的服务请求生命周期
3. **设置** [Webhooks](/cn/webhook-reference/introduction) 实时状态更新
