Skip to main content
Glama

lokalise_bulk_update_translations

Batch update translations by supplying translation IDs and new data. Change text, mark as reviewed or unverified, and assign custom statuses for up to 100 translations per request.

Instructions

Efficiently processes batch translation corrections or approvals. Required: projectId, updates array (up to 100). Each update needs translation_id plus changes. Use for mass approvals, systematic corrections, or importing reviewed content. Returns: Success/error per translation. Performance: ~5 updates/second with automatic rate limiting and retries.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdYesProject ID containing the translations
updatesYesArray of translation updates (min 1, max 100). Each update includes translationId and translationData

Implementation Reference

  • The main MCP tool handler function for lokalise_bulk_update_translations. It receives args with projectId and updates array, delegates to translationsController.bulkUpdateTranslations, and formats the response.
    async function handleBulkUpdateTranslations(
    	args: BulkUpdateTranslationsToolArgsType,
    ) {
    	const methodLogger = Logger.forContext(
    		"translations.tool.ts",
    		"handleBulkUpdateTranslations",
    	);
    	methodLogger.debug("Bulk updating translations...", {
    		projectId: args.projectId,
    		updateCount: args.updates.length,
    	});
    
    	try {
    		const result = await translationsController.bulkUpdateTranslations(args);
    		methodLogger.debug("Got the response from the controller", result);
    
    		return {
    			content: [
    				{
    					type: "text" as const,
    					text: result.content,
    				},
    			],
    		};
    	} catch (error) {
    		methodLogger.error("Tool failed", {
    			error: (error as Error).message,
    			args,
    		});
    		return formatErrorForMcpTool(error);
    	}
    }
  • Registration of the lokalise_bulk_update_translations tool with the MCP server, binding the name, description, Zod schema (BulkUpdateTranslationsToolArgs.shape), and the handler function handleBulkUpdateTranslations.
    server.tool(
    	"lokalise_bulk_update_translations",
    	"Efficiently processes batch translation corrections or approvals. Required: projectId, updates array (up to 100). Each update needs translation_id plus changes. Use for mass approvals, systematic corrections, or importing reviewed content. Returns: Success/error per translation. Performance: ~5 updates/second with automatic rate limiting and retries.",
    	BulkUpdateTranslationsToolArgs.shape,
    	handleBulkUpdateTranslations,
    );
  • BulkUpdateTranslationsToolArgs Zod schema defining input validation: projectId (string), updates (array of {translationId, translationData} min 1 max 100). Also exports BulkUpdateTranslationsToolArgsType, BulkUpdateTranslationResult, and BulkUpdateTranslationsSummary interfaces.
    /**
     * Zod schema for bulk update translations tool arguments.
     * Allows updating multiple translations in a single operation.
     */
    export const BulkUpdateTranslationsToolArgs = z
    	.object({
    		projectId: z.string().describe("Project ID containing the translations"),
    		updates: z
    			.array(
    				z.object({
    					translationId: z.number().describe("Translation ID to update"),
    					translationData: z
    						.object({
    							translation: z.string().describe("The updated translation text"),
    							isReviewed: z
    								.boolean()
    								.optional()
    								.describe("Mark translation as reviewed"),
    							isUnverified: z
    								.boolean()
    								.optional()
    								.describe("Mark translation as unverified (fuzzy)"),
    							customTranslationStatusIds: z
    								.array(z.number())
    								.optional()
    								.describe("Array of custom translation status IDs (numeric)"),
    						})
    						.describe("Translation data to update"),
    				}),
    			)
    			.min(1)
    			.max(100)
    			.describe(
    				"Array of translation updates (min 1, max 100). Each update includes translationId and translationData",
    			),
    	})
    	.strict();
    
    export type BulkUpdateTranslationsToolArgsType = z.infer<
    	typeof BulkUpdateTranslationsToolArgs
    >;
  • The bulkUpdate service method that processes each translation update sequentially with rate limiting (200ms delay, ~5/sec) and retry logic (max 3 attempts). Returns a BulkUpdateTranslationsSummary with per-translation results.
    	async bulkUpdate(
    		args: BulkUpdateTranslationsToolArgsType,
    	): Promise<BulkUpdateTranslationsSummary> {
    		const methodLogger = logger.forMethod("bulkUpdate");
    		methodLogger.info("Starting bulk translation update", {
    			projectId: args.projectId,
    			updateCount: args.updates.length,
    		});
    
    		const startTime = Date.now();
    		const results: BulkUpdateTranslationResult[] = [];
    		const RATE_LIMIT_DELAY = 200; // 200ms delay = max 5 requests/second
    		const MAX_RETRY_ATTEMPTS = 3;
    		const RETRY_DELAY = 1000; // 1 second delay between retries
    
    		// Helper function to update a single translation with retry logic
    		const updateWithRetry = async (
    			update: (typeof args.updates)[0],
    			attemptNumber = 1,
    		): Promise<BulkUpdateTranslationResult> => {
    			try {
    				const updateArgs: UpdateTranslationToolArgsType = {
    					projectId: args.projectId,
    					translationId: update.translationId,
    					translationData: update.translationData,
    				};
    
    				const translation = await this.update(updateArgs);
    
    				return {
    					translationId: update.translationId,
    					success: true,
    					translation,
    					attempts: attemptNumber,
    				};
    			} catch (error) {
    				const errorMessage =
    					error instanceof Error ? error.message : String(error);
    
    				if (attemptNumber < MAX_RETRY_ATTEMPTS) {
    					methodLogger.warn(
    						`Translation update failed, retrying (attempt ${attemptNumber}/${MAX_RETRY_ATTEMPTS})`,
    						{
    							translationId: update.translationId,
    							error: errorMessage,
    							attemptNumber,
    						},
    					);
    
    					// Wait before retry
    					await new Promise((resolve) => setTimeout(resolve, RETRY_DELAY));
    
    					// Retry
    					return updateWithRetry(update, attemptNumber + 1);
    				}
    
    				// Max retries reached, record as failure
    				methodLogger.error("Translation update failed after max retries", {
    					translationId: update.translationId,
    					error: errorMessage,
    					attempts: attemptNumber,
    				});
    
    				return {
    					translationId: update.translationId,
    					success: false,
    					error: errorMessage,
    					attempts: attemptNumber,
    				};
    			}
    		};
    
    		// Process updates sequentially with rate limiting
    		for (let i = 0; i < args.updates.length; i++) {
    			const update = args.updates[i];
    
    			methodLogger.info(
    				`Processing translation ${i + 1}/${args.updates.length}`,
    				{
    					translationId: update.translationId,
    				},
    			);
    
    			// Perform the update
    			const result = await updateWithRetry(update);
    			results.push(result);
    
    			// Rate limiting: delay before next request (except for the last one)
    			if (i < args.updates.length - 1) {
    				await new Promise((resolve) => setTimeout(resolve, RATE_LIMIT_DELAY));
    			}
    		}
    
    		// Calculate summary
    		const duration = Date.now() - startTime;
    		const successCount = results.filter((r) => r.success).length;
    		const failureCount = results.filter((r) => !r.success).length;
    
    		const summary: BulkUpdateTranslationsSummary = {
    			totalRequested: args.updates.length,
    			successCount,
    			failureCount,
    			results,
    			duration,
    		};
    
    		methodLogger.info("Bulk translation update completed", {
    			projectId: args.projectId,
    			totalRequested: summary.totalRequested,
    			successCount: summary.successCount,
    			failureCount: summary.failureCount,
    			durationMs: summary.duration,
    		});
    
    		return summary;
    	},
    };
  • The formatBulkUpdateTranslationsResult function that formats the bulk update summary into a Markdown response showing success/failure counts, tables of successful and failed updates, and performance notes.
    export function formatBulkUpdateTranslationsResult(
    	summary: BulkUpdateTranslationsSummary,
    ): string {
    	const lines: string[] = [];
    
    	// Add main heading
    	lines.push(formatHeading("Bulk Translation Update Results", 1));
    	lines.push("");
    
    	// Add overall summary
    	lines.push(formatHeading("Summary", 2));
    	const overallSummary: Record<string, unknown> = {
    		"Total Translations": summary.totalRequested,
    		"Successful Updates": `${summary.successCount} (${Math.round((summary.successCount / summary.totalRequested) * 100)}%)`,
    		"Failed Updates": `${summary.failureCount} (${Math.round((summary.failureCount / summary.totalRequested) * 100)}%)`,
    		"Total Duration": `${(summary.duration / 1000).toFixed(2)} seconds`,
    		"Average Time per Translation": `${(summary.duration / summary.totalRequested / 1000).toFixed(2)} seconds`,
    	};
    	lines.push(formatBulletList(overallSummary));
    	lines.push("");
    
    	// Add successful updates section if any
    	if (summary.successCount > 0) {
    		lines.push(formatHeading("✅ Successful Updates", 2));
    		const successfulResults = summary.results.filter((r) => r.success);
    
    		const successTable = successfulResults.slice(0, 10).map((result) => ({
    			id: result.translationId.toString(),
    			language: result.translation?.language_iso || "N/A",
    			reviewed: result.translation?.is_reviewed ? "✓" : "✗",
    			attempts: result.attempts.toString(),
    		}));
    
    		const table = formatTable(successTable, [
    			{ key: "id", header: "Translation ID" },
    			{ key: "language", header: "Language" },
    			{ key: "reviewed", header: "Reviewed" },
    			{ key: "attempts", header: "Attempts" },
    		]);
    		lines.push(table);
    
    		if (successfulResults.length > 10) {
    			lines.push(
    				`*... and ${successfulResults.length - 10} more successful updates*`,
    			);
    		}
    		lines.push("");
    	}
    
    	// Add failed updates section if any
    	if (summary.failureCount > 0) {
    		lines.push(formatHeading("❌ Failed Updates", 2));
    		const failedResults = summary.results.filter((r) => !r.success);
    
    		const failureTable = failedResults.map((result) => ({
    			id: result.translationId.toString(),
    			error: result.error || "Unknown error",
    			attempts: result.attempts.toString(),
    		}));
    
    		const table = formatTable(failureTable, [
    			{ key: "id", header: "Translation ID" },
    			{
    				key: "error",
    				header: "Error",
    				formatter: (v) => {
    					const error = String(v);
    					return error.length > 50 ? `${error.substring(0, 50)}...` : error;
    				},
    			},
    			{ key: "attempts", header: "Attempts" },
    		]);
    		lines.push(table);
    		lines.push("");
    	}
    
    	// Add performance notes
    	if (summary.totalRequested > 20) {
    		lines.push(formatHeading("Performance Notes", 2));
    		const performanceNotes = {
    			"Rate Limiting": "~5 requests per second",
    			"Retry Logic": "Up to 3 attempts per translation on failure",
    			Recommendation: "Consider smaller batches for better performance",
    		};
    		lines.push(formatBulletList(performanceNotes));
    		lines.push("");
    	}
    
    	// Add footer
    	lines.push(formatFooter("Bulk update completed"));
    
    	return lines.join("\n");
    }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description fully bears the burden. It discloses performance (~5 updates/second), automatic rate limiting, retries, and return format (success/error per translation). It does not detail idempotency or partial failure handling, but the provided traits are sufficient for an agent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is four sentences, each adding value: first states purpose, second lists requirements, third provides use cases, fourth gives performance and output. No unnecessary words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (batch updates with nested array) and full schema coverage, the description covers input constraints, performance, and return format adequately. It omits edge cases but for a batch tool, the provided information is nearly complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%. Description summarizes required fields and array limits, but adds only minor clarification (e.g., 'Each update needs translation_id plus changes') beyond the schema. Baseline 3 is appropriate since the schema already documents parameters well.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it handles batch translation corrections or approvals, using the verb 'processes batch', which distinguishes it from the sibling tool 'lokalise_update_translation' (single update). It specifies the resource (translations) and the batch nature.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description lists use cases: mass approvals, systematic corrections, importing reviewed content. It outlines required parameters and limits (up to 100 updates) but does not explicitly state when to use alternatives (e.g., single update tool) or when not to use this tool.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/AbdallahAHO/lokalise-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server