bulkWriteTranslations
Update multiple translations efficiently in batch operations for Weblate projects. Specify project, component, language code, and translations to streamline updates across large datasets.
Instructions
Update multiple translations in batch for efficient bulk operations
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| componentSlug | Yes | The slug of the component | |
| languageCode | Yes | The language code (e.g., en, es, fr) | |
| projectSlug | Yes | The slug of the project | |
| translations | Yes | Array of translations to update |
Implementation Reference
- src/tools/translations.tool.ts:215-228 (registration)Tool registration using @Tool decorator from @rekog/mcp-nest, specifying name 'bulkWriteTranslations', description, and input schema.@Tool({ name: 'bulkWriteTranslations', description: 'Update multiple translations in batch for efficient bulk operations', parameters: z.object({ projectSlug: z.string().describe('The slug of the project'), componentSlug: z.string().describe('The slug of the component'), languageCode: z.string().describe('The language code (e.g., en, es, fr)'), translations: z.array(z.object({ key: z.string().describe('The translation key to update'), value: z.string().describe('The new translation value'), markAsApproved: z.boolean().optional().describe('Whether to mark as approved (default: false)').default(false), })).describe('Array of translations to update'), }), })
- Zod schema defining input parameters for the bulkWriteTranslations tool: projectSlug (string), componentSlug (string), languageCode (string), translations (array of {key, value, markAsApproved?}).parameters: z.object({ projectSlug: z.string().describe('The slug of the project'), componentSlug: z.string().describe('The slug of the component'), languageCode: z.string().describe('The language code (e.g., en, es, fr)'), translations: z.array(z.object({ key: z.string().describe('The translation key to update'), value: z.string().describe('The new translation value'), markAsApproved: z.boolean().optional().describe('Whether to mark as approved (default: false)').default(false), })).describe('Array of translations to update'), }),
- src/tools/translations.tool.ts:229-300 (handler)The core handler function for bulkWriteTranslations tool. It delegates the API call to WeblateApiService, processes the result to create a formatted summary of successful and failed updates, handles errors, and returns structured content response.async bulkWriteTranslations({ projectSlug, componentSlug, languageCode, translations, }: { projectSlug: string; componentSlug: string; languageCode: string; translations: Array<{ key: string; value: string; markAsApproved?: boolean; }>; }) { try { const result = await this.weblateApiService.bulkWriteTranslations( projectSlug, componentSlug, languageCode, translations, ); let resultText = `Bulk translation update completed for ${projectSlug}/${componentSlug}/${languageCode}\n\n`; resultText += `📊 **Summary:**\n`; resultText += `- Total: ${result.summary.total}\n`; resultText += `- ✅ Successful: ${result.summary.successful}\n`; resultText += `- ❌ Failed: ${result.summary.failed}\n\n`; if (result.successful.length > 0) { resultText += `✅ **Successfully Updated (${result.successful.length}):**\n`; result.successful.slice(0, 10).forEach(({ key }) => { resultText += `- ${key}\n`; }); if (result.successful.length > 10) { resultText += `... and ${result.successful.length - 10} more\n`; } resultText += '\n'; } if (result.failed.length > 0) { resultText += `❌ **Failed Updates (${result.failed.length}):**\n`; result.failed.slice(0, 5).forEach(({ key, error }) => { resultText += `- ${key}: ${error}\n`; }); if (result.failed.length > 5) { resultText += `... and ${result.failed.length - 5} more failures\n`; } } return { content: [ { type: 'text', text: resultText, }, ], }; } catch (error) { this.logger.error(`Failed to bulk write translations`, error); return { content: [ { type: 'text', text: `Error during bulk translation update: ${error.message}`, }, ], isError: true, }; } }