# General Translation Platform: enqueueFiles URL: https://generaltranslation.com/ja/docs/platform/core/reference/gt-class-methods/translation/enqueue-files.mdx --- title: enqueueFiles description: アップロード済みのソースファイルを、1 つ以上の対象ロケールへの翻訳用キューに追加します。enqueueFiles の API リファレンス。 --- General Translation で、事前にアップロードしたソースファイルの翻訳ジョブをキューに追加します。ファイル参照を受け取り、対象ロケールごとに翻訳ジョブを作成します。 ## 概要 [#overview] [`uploadSourceFiles`](/docs/platform/core/reference/gt-class-methods/translation/upload-source-files) から返されたファイル参照と、対象ロケールを列挙したオプションオブジェクトを指定して `enqueueFiles` を呼び出します。 ```typescript const gt = new GT({ projectId: 'your-project-id', apiKey: 'your-api-key' }); const result = await gt.enqueueFiles(fileRefs, { sourceLocale: 'en', targetLocales: ['es', 'fr', 'de'], }); ``` シグネチャ: ```typescript enqueueFiles( files: FileReferenceIds[], options: EnqueueFilesOptions ): Promise ``` *注記: `enqueueFiles` を使用するには、GT インスタンスに `apiKey` (または `devApiKey`) と `projectId` が設定されている必要があります。ファイルをキューに追加できるのは、アップロード後のみです。* ## 仕組み [#how-it-works] * **非同期ジョブ。** 翻訳ジョブは非同期で実行されます。進行状況は [`queryFileData`](/docs/platform/core/reference/gt-class-methods/translation/query-file-data) で確認するか、[`awaitJobs`](/docs/platform/core/reference/gt-class-methods/translation/await-jobs) で完了まで待機できます。 * **ロケールごとに 1 つのジョブ。** レスポンスの `jobData` はジョブ ID をキーとし、対象ロケールごとに 1 つのジョブが作成されます。 * **バージョン管理。** ファイル参照には、ブランチ対応のバージョン管理用に `branchId` が含まれます。 ## パラメータ [#parameters] | パラメータ | 説明 | 型 | 任意 | デフォルト | | --------------------- | ---------------------- | ---------------------------------------------------------------------------------- | --- | ----- | | [`files`](#files) | 事前にアップロードしたファイルの参照 ID。 | `FileReferenceIds[]` | いいえ | — | | [`options`](#options) | 翻訳ジョブの設定オプション。 | [`EnqueueFilesOptions`](/docs/platform/core/reference/types/enqueue-files-options) | いいえ | — | ### `files` [#files] **型** `FileReferenceIds[]` · **必須** エンキューするファイル参照: ```typescript type FileReferenceIds = { fileId: string; versionId: string; branchId?: string; fileName?: string; fileFormat?: FileFormat; transformFormat?: FileFormat; // 生成された翻訳に要求される出力フォーマット dataFormat?: DataFormat; }; ``` | Field | 説明 | 型 | 任意 | | ----------------- | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- | --- | | `fileId` | 一意のファイル識別子。 | `string` | いいえ | | `versionId` | バージョン識別子。 | `string` | いいえ | | `branchId` | ブランチ識別子。 | `string` | はい | | `fileName` | ファイル名。 | `string` | はい | | `fileFormat` | ファイル形式。`GTJSON`、`JSON`、`PO`、`POT`、`YAML`、`MDX`、`MD`、`TS`、`JS`、`HTML`、`TXT`、`TWILIO_CONTENT_JSON` のいずれか。 | `FileFormat` | はい | | `transformFormat` | 生成される翻訳の出力形式。 | `FileFormat` | はい | | `dataFormat` | ファイル内のデータ形式 (ICU、I18NEXT、JSX、STRING) 。 | [`DataFormat`](/docs/platform/core/reference/types/data-format) | はい | ### `options` [#options] **Type** [`EnqueueFilesOptions`](/docs/platform/core/reference/types/enqueue-files-options) · **必須** translation job の設定: | フィールド | 説明 | Type | 任意 | デフォルト | | --------------- | ---------------------------------------- | ---------- | --- | ---------------------- | | `sourceLocale` | 翻訳元のロケール。 | `string` | はい | インスタンスの `sourceLocale` | | `targetLocales` | 対象ロケール。 | `string[]` | いいえ | — | | `modelProvider` | 翻訳に使用する特定の AI モデルプロバイダー。 | `string` | はい | — | | `force` | キャッシュ済みの翻訳を無効化し、すでに翻訳が存在する場合でも再翻訳を強制します。 | `boolean` | はい | — | | `timeout` | リクエストタイムアウト (ミリ秒) 。 | `number` | はい | — | *注: `requireApproval` は 8.x 専用のオプションで、9.0 にはありません。* ## 戻り値 [#returns] **型** `Promise` ジョブ情報と処理の詳細を含む `EnqueueFilesResult` が返されます。 ```typescript type EnqueueFilesResult = { jobData: { [jobId: string]: { sourceFileId: string; fileId: string; versionId: string; branchId: string; targetLocale: string; projectId: string; force: boolean; modelProvider?: string; }; }; locales: string[]; // ジョブの対象ロケール message: string; // APIからのステータスメッセージ }; ``` `jobData` レコードはジョブ ID をキーとする構造で、各値は 1 件の翻訳ジョブを表します。 ## 例 [#examples] ```typescript title="index.ts" // (1) GTインスタンスを作成する const targetLocales = ['es', 'fr', 'de']; const gt = new GT({ projectId: 'your-project-id', apiKey: 'your-api-key', }); // (2) ファイルをアップロードする const fileUpload = { content: fileContents, fileName: filePath, fileFormat: 'JSON', locale: 'en', }; const files = [{ source: fileUpload }]; const { uploadedFiles } = await gt.uploadSourceFiles(files, { sourceLocale: 'en' }); // (3) ファイルの翻訳ジョブをキューに追加する const enqueueResult = await gt.enqueueFiles(uploadedFiles, { sourceLocale: 'en', targetLocales: targetLocales, }); console.log(`Created ${Object.keys(enqueueResult.jobData).length} translation jobs`); // (4) すべての翻訳が完了するまで待機する const { fileId, versionId, branchId } = uploadedFiles[0]; const translatedFileQueries = targetLocales.map((locale) => ({ fileId, versionId, branchId, locale, })); while (true) { const result = await gt.queryFileData({ translatedFiles: translatedFileQueries, }); const allCompleted = result.translatedFiles?.every((file) => file.completedAt !== null); if (allCompleted) { break; } await new Promise((resolve) => setTimeout(resolve, 1000)); } // (5) ファイルをダウンロードする const downloadResult = await gt.downloadFileBatch( targetLocales.map((locale) => ({ fileId, branchId, locale, })) ); ``` ## メモ [#notes] * ファイルの内容は、まず [`uploadSourceFiles`](/docs/platform/core/reference/gt-class-methods/translation/upload-source-files) を使ってアップロードする必要があります。 * 翻訳ジョブは非同期で実行されます。進行状況の確認には [`queryFileData`](/docs/platform/core/reference/gt-class-methods/translation/query-file-data) または [`awaitJobs`](/docs/platform/core/reference/gt-class-methods/translation/await-jobs) を使用してください。 * ファイル参照には、ブランチを使ったバージョン管理のための `branchId` が含まれます。