writeTranslation
Update or add translations for specific keys in Weblate projects by specifying project, component, language, and translation value. Mark translations as approved for immediate use.
Instructions
Update or write a translation value for a specific key
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| componentSlug | Yes | The slug of the component | |
| key | Yes | The translation key to update | |
| languageCode | Yes | The language code (e.g., en, es, fr) | |
| markAsApproved | No | Whether to mark as approved (default: false) | |
| projectSlug | Yes | The slug of the project | |
| value | Yes | The new translation value |
Implementation Reference
- src/tools/translations.tool.ts:166-213 (handler)The main execution logic for the 'writeTranslation' MCP tool. It takes input parameters, calls the WeblateApiService to perform the update, handles errors, and returns a formatted response.async writeTranslation({ projectSlug, componentSlug, languageCode, key, value, markAsApproved = false, }: { projectSlug: string; componentSlug: string; languageCode: string; key: string; value: string; markAsApproved?: boolean; }) { try { const updatedUnit = await this.weblateApiService.writeTranslation( projectSlug, componentSlug, languageCode, key, value, markAsApproved, ); return { content: [ { type: 'text', text: updatedUnit ? `Successfully updated translation for key "${key}"\n\n${this.formatTranslationResult(updatedUnit)}` : `Failed to update translation for key "${key}"`, }, ], }; } catch (error) { this.logger.error(`Failed to write translation for key ${key}`, error); return { content: [ { type: 'text', text: `Error writing translation for key "${key}": ${error.message}`, }, ], isError: true, }; } }
- The @Tool decorator defining the tool name, description, and Zod input schema for validation.@Tool({ name: 'writeTranslation', description: 'Update or write a translation value for a specific key', 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)'), 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), }), })
- src/app.module.ts:77-77 (registration)The WeblateTranslationsTool class is provided in the AppModule's providers array, enabling auto-registration of its @Tool methods for the MCP server.WeblateTranslationsTool,