# generaltranslation: General Translation Core SDK: EntryMetadata URL: https://generaltranslation.com/zh/docs/core/types/entry-metadata.mdx --- title: EntryMetadata description: 用于自定义翻译行为的元数据类型定义 --- ## 概述 `EntryMetadata` 为翻译操作中的 [`TranslateManyEntry`](/docs/core/types/Entry) 对象提供可选的配置项。 ```typescript type EntryMetadata = { id?: string; hash?: string; context?: string; maxChars?: number; dataFormat?: DataFormat; actionType?: ActionType; }; ``` ## 属性 | 属性 | 类型 | 描述 | | ------------- | -------------------------------------------- | -------------------------------------------------- | | `id?` | `string` | 条目的唯一标识符 | | `hash?` | `string` | 用于缓存和去重的内容哈希值 | | `context?` | `string` | 为译者提供的上下文提示 (例如“按钮文本”“导航菜单”) | | `maxChars?` | `number` | 译文的最大字符限制 | | `dataFormat?` | [`DataFormat`](/docs/core/types/data-format) | 内容格式规范 (`'JSX'`、`'ICU'`、`'I18NEXT'` 或 `'STRING'`) | | `actionType?` | `ActionType` | 翻译模型偏好设置 | ### 相关类型 ```typescript type DataFormat = 'JSX' | 'ICU' | 'I18NEXT' | 'STRING'; type ActionType = 'fast'; ``` ## 示例 ### 基本用法 ```typescript copy import { GT, TranslateManyEntry } from 'generaltranslation'; const entry: TranslateManyEntry = { source: 'Save', metadata: { context: 'Button text', actionType: 'fast' } }; const gt = new GT({ apiKey: 'your-api-key', projectId: 'your-project-id' }); const result = await gt.translate(entry, 'es'); ``` ### 使用 ICU 格式 ```typescript copy const entry: TranslateManyEntry = { source: '{count, plural, other {{count} items}}', metadata: { dataFormat: 'ICU', context: 'Item count' } }; ``` ## 相关类型 * [`TranslateManyEntry`](/docs/core/types/Entry) - 使用此元数据的上级类型 * [`DataFormat`](/docs/core/types/data-format) - 内容格式选项