# generaltranslation: General Translation Core SDK: queryFileData URL: https://generaltranslation.com/ja/docs/core/class/methods/translation/query-file-data.mdx --- title: queryFileData description: ソースファイルと翻訳ファイルのデータを照会する queryFileData メソッドの API リファレンス --- ## 概要 `queryFileData` メソッドは、1 つ以上のソースファイルまたは翻訳済みファイルに関するデータを取得します。 これは、翻訳の進捗状況の監視、完了ステータスの確認、利用可能な翻訳の特定に役立ちます。 ```typescript const gt = new GT({ projectId: 'your-project-id', apiKey: 'your-api-key' }); const result = await gt.queryFileData({ sourceFiles: [ { fileId: 'file-123', versionId: 'version-456', branchId: 'branch-789' } ], translatedFiles: [ { fileId: 'file-123', versionId: 'version-456', branchId: 'branch-789', locale: 'es' } ] }); ``` ## リファレンス ### パラメーター | 名前 | 型 | 説明 | | ---------- | ------------------------------ | --------------------------- | | `data` | `FileDataQuery` | ソースファイルと翻訳ファイルのクエリを含むオブジェクト | | `options?` | `CheckFileTranslationsOptions` | リクエストのオプション設定 | #### FileDataQuery ```typescript type FileDataQuery = { sourceFiles?: { fileId: string; versionId: string; branchId: string; }[]; translatedFiles?: { fileId: string; versionId: string; branchId: string; locale: string; }[]; } ``` | 名前 | 型 | 説明 | | ------------------ | ---------- | ------------- | | `sourceFiles?` | `object[]` | ソースファイルクエリ配列 | | `translatedFiles?` | `object[]` | 翻訳済みファイルクエリ配列 | #### CheckFileTranslationsOptions | Name | Type | Description | | ---------- | -------- | --------------------- | | `timeout?` | `number` | リクエストのタイムアウト時間 (ミリ秒) | ### 戻り値 `Promise` - ソースファイルと翻訳ファイルのデータが含まれます。 ```typescript type FileDataResult = { sourceFiles?: { branchId: string; fileId: string; versionId: string; fileName: string; fileFormat: string; dataFormat: string | null; createdAt: string; updatedAt: string; approvalRequiredAt: string | null; publishedAt: string | null; locales: string[]; sourceLocale: string; }[]; translatedFiles?: { fileId: string; versionId: string; branchId: string; locale: string; fileFormat: string; dataFormat: string | null; completedAt: string | null; approvedAt: string | null; publishedAt: string | null; createdAt: string; updatedAt: string; }[]; } ``` | プロパティ | 型 | 説明 | | ----------------- | ---------- | ------------- | | `sourceFiles` | `object[]` | ソースファイルデータの配列 | | `translatedFiles` | `object[]` | 翻訳状況データの配列 | *** ## 使用例 ### 基本的な使い方 特定のソースファイルと翻訳済みファイルのデータを取得します。 ```typescript title="index.ts" copy // (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, } ); // (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( translatedFileQueries.map(({ fileId, branchId, locale }) => ({ fileId, branchId, locale })) ); ``` *** ## 注記 * `completedAt` が `null` でない場合、その翻訳は完了しています * 翻訳が完了していても、公開 (`publishedAt`) 前に承認 (`approvedAt`) が必要な場合があります * 複数の翻訳ジョブを監視する際のステータス確認には、このメソッドを使用すると効率的です * すべてのファイルクエリで、適切なバージョニングのために `branchId` が必要です ## 次のステップ * このメソッドの使用方法をひととおり確認するには、[Quickstart](/docs/core/quickstart#translate-your-first-file)の完全な例を参照してください * 完了した翻訳をダウンロードするには、[`downloadFile`](/docs/core/class/methods/translation/download-file)を参照してください * 翻訳ジョブを作成するには、[`enqueueFiles`](/docs/core/class/methods/translation/enqueue-files)を参照してください * ソースファイルと翻訳情報を取得するには、[`querySourceFile`](/docs/core/class/methods/translation/query-source-file)を参照してください