Entry
バッチ翻訳で使用される翻訳 Entry の型定義
概要
Entry は、translateMany を用いるバッチ翻訳処理のための翻訳リクエストオブジェクトを表します。
type Entry = {
  source: Content;
  targetLocale?: string;
  metadata?: EntryMetadata;
};プロパティ
| プロパティ | 型 | 説明 | 
|---|---|---|
| source | Content | 翻訳対象のソースコンテンツ | 
| targetLocale? | string | 対象のlocale(インスタンスのtargetLocaleが既定として使用されます) | 
| metadata? | EntryMetadata | 翻訳をカスタマイズするための任意のメタデータ | 
コンテンツタイプ
type Content = JsxChildren | I18nextMessage | IcuMessage | string;EntryMetadata
type EntryMetadata = {
  context?: string;
  id?: string;
  hash?: string;
  dataFormat?: DataFormat;
  sourceLocale?: string;
  actionType?: ActionType;
  timeout?: number;
  regionCode?: string;
  scriptCode?: string;
};ActionType(アクションタイプ)
type ActionType = 'standard' | 'fast' | string;- 'standard'- 高品質な翻訳モデル
- 'fast'- 低遅延の翻訳モデル
例
基本的な使用方法
import { Entry } from 'generaltranslation';
const entries: Entry[] = [
  {
    source: 'Hello, world!',
    targetLocale: 'es'
  },
  {
    source: 'Good morning',
    targetLocale: 'de',
    metadata: {
      context: 'Formal greeting',
      actionType: 'standard'
    }
  }
];translateMany() の使用
import { GT } from 'generaltranslation';
const gt = new GT({
  apiKey: 'your-api-key',
  sourceLocale: 'en'
});
const entries: Entry[] = [
  { source: 'Home', targetLocale: 'es' },
  { source: 'About', targetLocale: 'es' }
];
const results = await gt.translateMany(entries);関連する型
- EntryMetadata- メタデータ用のoptions
- TranslateManyResult- 一括翻訳の結果
このガイドはどうでしたか?

