# General Translation Platform: FileToTranslate(旧版)
URL: https://generaltranslation.com/zh/docs/platform/core/reference/types/file-to-translate.mdx
---
title: FileToTranslate(旧版)
description: 介绍已从 Core v9 中移除的旧版文件输入及其当前替代方案。FileToTranslate 的 API 参考。
---
`FileToTranslate` 表示 Core 8.x 批量翻译工作流中的文件对象。`generaltranslation` 9.x 不再导出此对象。
**v9 中的变更:** `FileToTranslate` 已移除。请使用 `FileToUpload` 调用 [`uploadSourceFiles`](/docs/platform/core/reference/gt-class-methods/translation/upload-source-files),然后将返回的文件引用传递给 [`enqueueFiles`](/docs/platform/core/reference/gt-class-methods/translation/enqueue-files)。
## 概览 [#overview]
旧版类型将文件的原始内容、名称和格式整合在一起:
```typescript
type FileToTranslate = {
content: string;
fileName: string;
fileFormat: FileFormat;
formatMetadata?: Record;
dataFormat?: DataFormat;
};
```
## 属性 [#properties]
| 属性 | 描述 | 类型 | 可选 |
| ------------------------------------ | ---------- | --------------------------------------------------------------- | -- |
| [`content`](#content) | 文件原始内容。 | `string` | 否 |
| [`fileName`](#file-name) | 文件标识。 | `string` | 否 |
| [`fileFormat`](#file-format) | 旧版文件格式标识符。 | string 联合类型 | 否 |
| [`formatMetadata`](#format-metadata) | 格式专用元数据。 | `Record` | 是 |
| [`dataFormat`](#data-format) | 文件内的数据格式。 | [`DataFormat`](/docs/platform/core/reference/types/data-format) | 是 |
### `content` [#content]
**类型** `string` · **必填**
文件原始内容。
### `fileName` [#file-name]
**类型** `string` · **必填**
文件标识,如 `common.json` 或 `docs/start.mdx`。
### `fileFormat` [#file-format]
**类型** 字符串联合类型 · **必填**
旧版文件格式标识符,例如 `'JSON'`、`'PO'`、`'MDX'` 或 `'HTML'`。
### `formatMetadata` [#format-metadata]
**类型** `Record` · **可选**
格式专用元数据。
### `dataFormat` [#data-format]
**类型** [`DataFormat`](/docs/platform/core/reference/types/data-format) · **可选**
文件中的数据格式:`'JSX'`、`'ICU'` 或 `'I18NEXT'`。
## 旧版示例 [#legacy-example]
```typescript
// 仅适用于 generaltranslation 8.x
import type { FileToTranslate } from 'generaltranslation';
// JSON 文件
const jsonFile: FileToTranslate = {
content: JSON.stringify({
"welcome": "Welcome",
"save": "Save"
}),
fileName: 'common.json',
fileFormat: 'JSON',
dataFormat: 'I18NEXT'
};
```
```typescript
// MDX 文件
const mdxFile: FileToTranslate = {
content: `# Getting Started\n\nWelcome to our platform!`,
fileName: 'docs/start.mdx',
fileFormat: 'MDX',
dataFormat: 'JSX'
};
```
## 当前替代方案 [#replacement]
在 9.x 中,从 `generaltranslation/types` 导入 `FileToUpload`,上传源文件,并在后续操作中使用返回的引用:
```typescript
import { GT } from 'generaltranslation';
import type { FileToUpload } from 'generaltranslation/types';
const gt = new GT({
apiKey: process.env.GT_API_KEY,
projectId: process.env.GT_PROJECT_ID,
});
const source = {
content: JSON.stringify({ welcome: 'Welcome' }),
fileName: 'common.json',
fileFormat: 'JSON',
locale: 'en',
} satisfies FileToUpload;
const { uploadedFiles } = await gt.uploadSourceFiles(
[{ source }],
{ sourceLocale: 'en' }
);
```