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} 个项目}}',
targetLocale: 'es',
metadata: {
dataFormat: 'ICU',
context: '项目数量'
}
};相关类型
Entry- 使用该元数据的父类型ActionType- 翻译模型的选项
本指南如何?