DocumentationAmertaPayloadFieldsTranslateActionsTranslateBulkFunctions

Apply Translations

amerta


amerta / amerta/payload/fields/translate/actions/translateBulk / applyTranslations

Function: applyTranslations()

applyTranslations(collectionSlug, approvedData, targetLocale): Promise<{ count: number; error?: undefined; success: boolean; } | { count?: undefined; error: string; success: boolean; }>

Defined in: amerta/payload/fields/translate/actions/translateBulk.ts:118

Applies approved translations to documents in a Payload collection. Updates specified fields with their translated values and revalidates the collection path.

Parameters

| Parameter | Type | Description | | ------ | ------ | ------ | | collectionSlug | string | The slug of the Payload collection to update. | | approvedData | any[] | Array of objects containing document IDs and field translations to apply. | | targetLocale | string | The target language code for the translations. |

Returns

Promise<{ count: number; error?: undefined; success: boolean; } | { count?: undefined; error: string; success: boolean; }>

An object containing success status and the count of updated documents, or error message if failed.

Example

const result = await applyTranslations('products', [{ id: 'doc1', fields: [...] }], 'fr');