# General Translation Platform: TranslationResult URL: https://generaltranslation.com/en-GB/docs/platform/core/reference/types/translation-result.mdx --- title: TranslationResult description: Success or error result returned by General Translation translation methods. API reference for TranslationResult type. --- The result of a translation method such as [`translate`](/docs/platform/core/reference/gt-class-methods/translation/translate) or [`translateMany`](/docs/platform/core/reference/gt-class-methods/translation/translate-many). It is a discriminated union of a success result and an error result. ## Overview [#overview] `TranslationResult` is a union discriminated by the `success` boolean. Narrow on `success` to access either the translation or the error. ```typescript type TranslationResult = RequestSuccess | TranslationError; ``` ## Members [#members] | Member | Description | Type | | ---------------------------------------- | -------------------------------------------------------------------- | -------- | | [`RequestSuccess`](#request-success) | Successful translation, including the translated content and locale. | `object` | | [`TranslationError`](#translation-error) | Failed translation, including an error message and status code. | `object` | ### `RequestSuccess` [#request-success] **Type** `object` Returned when `success` is `true`. Includes the translated content and the resolved target `locale`. ```typescript type RequestSuccess = TypedResult & { success: true; locale: string; // resolved target locale }; ``` ### `TranslationError` [#translation-error] **Type** `object` Returned when `success` is `false`. Includes a human-readable `error` message and a numeric `code`. ```typescript type TranslationError = { success: false; error: string; // error message code: number; // status code }; ``` ## Example [#example] ```typescript import { GT } from 'generaltranslation'; import { TranslationResult } from 'generaltranslation/types'; const gt = new GT({ apiKey: 'your-api-key', projectId: 'your-project-id' }); const result: TranslationResult = await gt.translate('Hello', 'es'); if (result.success) { console.log(`Translation: ${result.translation}`); // result.translation and result.locale are available } else { console.error(`Translation failed: ${result.error} (${result.code})`); // result.error and result.code are available } ```