---
name: "TranslateContext.offTranslateError"
mode: "kit"
versionRequirements:
  - { name: "AIKit", version: "0.0.1" }
platform:
  - "iOS"
  - "Android"
title: "TranslateContext.offTranslateError - 取消监听翻译异常事件"
---

## TranslateContext.offTranslateError

> [VERSION] AIKit >= 0.0.1

> [PLATFORM] iOS, Android

### 方法签名

```typescript
TranslateContext.offTranslateError(listener: Function)
```

### 描述

取消监听翻译异常事件

### 参数

| 参数 | 类型 | 必填 | 默认值 | 描述 |
| --- | --- | --- | --- | --- |
| `listener` | `(params: Object) => void` | 是 | - | 事件监听回调函数 |

##### TranslateContext.offTranslateError.listener(params) 的属性

| 属性 | 类型 | 必填 | 默认值 | 最低版本 | 描述 |
| --- | --- | --- | --- | --- | --- |
| `contextId` | `string` | 是 | - | `2.1.0` | 翻译任务id |
| `code` | `number` | 是 | - | - | 错误码 |
| `message` | `string` | 否 | - | - | 错误消息 |


### 示例代码

```tsx
import { ai } from '@ray-js/ray'

const context = ai.generateTranslateTask({
  deviceId: "xx",
  dataTimeout: 30,
  originalLanguage: "zh",
  targetLanguage: "en",
  agentId: "xx",
});

const listener = function (res) {
  console.log(res);
};

context.onTranslateError(listener);
context.offTranslateError(listener);
```
