Entry
Type definition for translation entries used in batch translation operations
Overview
Entry represents a translation request object for batch translation operations using translateMany.
type Entry = {
source: Content;
targetLocale?: string;
metadata?: EntryMetadata;
};Properties
| Property | Type | Description |
|---|---|---|
source | Content | Source content to translate |
targetLocale? | string | Target locale (falls back to the instance’s targetLocale) |
metadata? | EntryMetadata | Optional metadata for translation customisation |
Content type
type Content = JsxChildren | I18nextMessage | IcuMessage | string;Entry metadata
type EntryMetadata = {
context?: string;
id?: string;
hash?: string;
dataFormat?: DataFormat;
sourceLocale?: string;
actionType?: ActionType;
timeout?: number;
regionCode?: string;
scriptCode?: string;
};Action type
type ActionType = 'standard' | 'fast' | string;'standard'- Higher‑quality translation model'fast'- Lower‑latency translation model
Examples
Basic usage
import { Entry } from 'generaltranslation';
const entries: Entry[] = [
{
source: 'Hello, world!',
targetLocale: 'es'
},
{
source: 'Good morning',
targetLocale: 'de',
metadata: {
context: 'Formal greeting',
actionType: 'standard'
}
}
];Using 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);Related Types
EntryMetadata- Metadata optionsTranslateManyResult- Batch translation results
How is this guide?