Entry

Type definition for translation entries used in batch translation operations

Overview

Entry represents a translation request object for batch translation operations with translateMany.

type Entry = {
  source: Content;
  targetLocale?: string;
  metadata?: EntryMetadata;
};

Properties

PropertyTypeDescription
sourceContentSource content to translate
targetLocale?stringTarget locale (falls back to instance targetLocale)
metadata?EntryMetadataOptional metadata for translation customization

Content Type

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' - 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'
    }
  }
];

With 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);

How is this guide?

Entry