Types
EntryMetadata
用于在 Entry 对象中自定义翻译行为的元数据类型定义
概览
EntryMetadata 为批量翻译操作中的 Entry 对象提供可选配置项。
type EntryMetadata = {
  context?: string;
  id?: string;
  hash?: string;
  dataFormat?: DataFormat;
  sourceLocale?: string;
  actionType?: ActionType;
  timeout?: number;
  regionCode?: string;
  scriptCode?: string;
};属性
| 属性 | 类型 | 说明 | 
|---|---|---|
| context? | string | 供译者参考的上下文 | 
| id? | string | 唯一标识符 | 
| hash? | string | 用于缓存的内容哈希 | 
| dataFormat? | DataFormat | 格式说明 | 
| sourceLocale? | string | 源语言(sourceLocale)覆盖值 | 
| actionType? | ActionType | 翻译模型偏好设置 | 
| timeout? | number | 请求超时时间(毫秒) | 
| regionCode? | string | ISO 地区代码 | 
| scriptCode? | string | ISO 文字脚本代码 | 
相关类型
type DataFormat = 'JSX' | 'ICU' | 'I18NEXT';
type ActionType = 'standard' | 'fast' | string;示例
基本用法
import { Entry, EntryMetadata } from 'generaltranslation';
const metadata: EntryMetadata = {
  context: '按钮文本',
  actionType: 'fast'
};
const entry: Entry = {
  source: '保存',
  targetLocale: 'es',
  metadata
};使用 ICU 格式
const icuEntry: Entry = {
  source: '{count, plural, other {{count} items}}',
  targetLocale: 'es',
  metadata: {
    dataFormat: 'ICU',
    context: '项目数量'
  }
};相关类型
- Entry- 使用此元数据的父类型
- ActionType- 翻译模型的 options
这份指南怎么样?

