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- メタデータのoptionsTranslateManyResult- 一括翻訳結果
このガイドはいかがですか?