# generaltranslation: General Translation Core SDK: querySourceFile URL: https://generaltranslation.com/ja/docs/core/class/methods/translation/query-source-file.mdx --- title: querySourceFile description: ソースファイルと翻訳情報を取得する querySourceFile メソッドの API リファレンス --- ## 概要 `querySourceFile` メソッドは、ソースファイルとそれに関連付けられたすべての翻訳について、包括的な情報を取得します。 これには、ファイルのメタデータ、すべてのロケールでの翻訳ステータス、作成・完了・承認・公開のタイムスタンプが含まれます。 ```typescript const gt = new GT({ projectId: 'your-project-id', apiKey: 'your-api-key' }); const result = await gt.querySourceFile({ fileId: 'file-123', versionId: 'version-456' }); console.log(`Source file: ${result.sourceFile.fileName}`); console.log(`Available in ${result.translations.length} locales`); ``` ## リファレンス ### パラメーター | 名前 | 型 | 説明 | | ---------- | ------------------------------ | --------------------------- | | `data` | `FileQuery` | 取得するファイルを指定するファイルクエリ オブジェクト | | `options?` | `CheckFileTranslationsOptions` | リクエストの任意の設定 | #### FileQuery | 名前 | 型 | 説明 | | ------------ | -------- | ---------------------------- | | `fileId` | `string` | クエリ対象のファイルの一意の識別子 | | `versionId?` | `string` | 特定のファイルバージョンに対する任意のバージョン ID | | `branchId?` | `string` | 特定の ブランチ に対する任意の ブランチ ID | #### CheckFileTranslationsOptions | 名前 | 型 | 説明 | | ---------- | -------- | --------------------- | | `timeout?` | `number` | リクエストのタイムアウト時間 (ミリ秒) | ### 戻り値 `Promise` - すべてのロケールのソースファイル情報と翻訳ステータスを含みます。 ```typescript type FileQueryResult = { sourceFile: { id: string; fileId: string; versionId: string; branchId: string; sourceLocale: string; fileName: string; fileFormat: string; dataFormat: string | null; createdAt: string; updatedAt: string; approvalRequiredAt: string | null; locales: string[]; }; translations: { locale: string; completedAt: string | null; approvedAt: string | null; publishedAt: string | null; createdAt: string | null; updatedAt: string | null; }[]; } ``` #### ソースファイルのプロパティ | プロパティ | 型 | 説明 | | -------------------- | ---------------- | ------------------------------ | | `id` | `string` | 内部データベース ID | | `fileId` | `string` | 一意のファイル識別子 | | `versionId` | `string` | バージョン識別子 | | `branchId` | `string` | ブランチ識別子 | | `sourceLocale` | `string` | ソース言語のロケール | | `fileName` | `string` | 元のファイル名 | | `fileFormat` | `string` | ファイル形式 (JSON、MD、MDX など) | | `dataFormat` | `string \| null` | ファイル内のデータ形式 (ICU、I18NEXT、JSX) | | `createdAt` | `string` | ファイル作成時の ISO タイムスタンプ | | `updatedAt` | `string` | 最終更新時の ISO タイムスタンプ | | `approvalRequiredAt` | `string \| null` | 承認リクエスト時の ISO タイムスタンプ | | `locales` | `string[]` | このファイルの対象ロケールの一覧 | #### 翻訳プロパティ | プロパティ | 型 | 説明 | | ------------- | ---------------- | --------------------- | | `locale` | `string` | 対象のロケールコード | | `completedAt` | `string \| null` | 翻訳完了時の ISO タイムスタンプ | | `approvedAt` | `string \| null` | 翻訳承認時の ISO タイムスタンプ | | `publishedAt` | `string \| null` | 翻訳公開時の ISO タイムスタンプ | | `createdAt` | `string \| null` | 翻訳ジョブ作成時の ISO タイムスタンプ | | `updatedAt` | `string \| null` | 最終翻訳更新時の ISO タイムスタンプ | *** ## 例 ```typescript title="index.ts" copy import { GT } from 'generaltranslation'; const gt = new GT({ projectId: 'your-project-id', apiKey: 'your-api-key' }); async function getFileInfo(fileId: string, versionId?: string) { const result = await gt.querySourceFile({ fileId, versionId }); console.log('=== Source File Info ==='); console.log(`Name: ${result.sourceFile.fileName}`); console.log(`Format: ${result.sourceFile.fileFormat}`); console.log(`Source Locale: ${result.sourceFile.sourceLocale}`); console.log(`Branch: ${result.sourceFile.branchId}`); console.log(`Created: ${new Date(result.sourceFile.createdAt).toLocaleString()}`); console.log(`Updated: ${new Date(result.sourceFile.updatedAt).toLocaleString()}`); console.log('\n=== Translation Status ==='); result.translations.forEach(translation => { console.log(`${translation.locale}:`); console.log(` Created: ${translation.createdAt ? new Date(translation.createdAt).toLocaleString() : 'Not started'}`); console.log(` Completed: ${translation.completedAt ? new Date(translation.completedAt).toLocaleString() : 'In progress'}`); console.log(` Published: ${translation.publishedAt ? new Date(translation.publishedAt).toLocaleString() : 'Not published'}`); }); return result; } const fileInfo = await getFileInfo('file-123', 'version-456'); ``` *** ## 注意事項 * すべての対象ロケールについて、ソースファイルと翻訳ステータスを返します * 翻訳タイムスタンプは、`createdAt` -> `completedAt` -> `approvedAt` -> `publishedAt` のライフサイクルに従います * タイムスタンプが null の場合は、その段階にまだ到達していないことを示します * ソースファイル内の `locales` 配列には、翻訳対象として設定されているすべての対象ロケールが含まれます * レスポンスには、branching をサポートした適切なバージョニングのために `branchId` が含まれます * 詳細なレポート、進捗管理、ファイル管理のワークフローには、このメソッドを使用します ## 次のステップ * 特定の翻訳のステータスを一括で確認するには、[`queryFileData`](/docs/core/class/methods/translation/query-file-data)を参照してください * 完了した翻訳をダウンロードするには、[`downloadFile`](/docs/core/class/methods/translation/download-file)を参照してください * ファイルの翻訳ジョブを開始するには、[`enqueueFiles`](/docs/core/class/methods/translation/enqueue-files)を参照してください * プロジェクトレベルの情報については、[`getProjectData`](/docs/core/class/methods/translation/get-project-data)を参照してください