getComponentLanguageProgress
Retrieve translation progress statistics for all languages in a specific component within a Weblate project using project and component slugs.
Instructions
Get translation progress for all languages in a component
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| componentSlug | Yes | The slug of the component | |
| projectSlug | Yes | The slug of the project |
Implementation Reference
- src/tools/statistics.tool.ts:172-216 (handler)The primary handler function for the 'getComponentLanguageProgress' MCP tool. It validates inputs via Zod schema, delegates to the statistics service for data retrieval, formats the response using a private method, and returns structured content or error.@Tool({ name: 'getComponentLanguageProgress', description: 'Get translation progress for all languages in a component', parameters: z.object({ projectSlug: z.string().describe('The slug of the project'), componentSlug: z.string().describe('The slug of the component'), }), }) async getComponentLanguageProgress({ projectSlug, componentSlug, }: { projectSlug: string; componentSlug: string; }) { try { const progress = await this.statisticsService.getComponentLanguageProgress( projectSlug, componentSlug, ); return { content: [ { type: 'text', text: this.formatComponentLanguageProgress(projectSlug, componentSlug, progress), }, ], }; } catch (error) { this.logger.error( `Failed to get component language progress for ${projectSlug}/${componentSlug}`, error, ); return { content: [ { type: 'text', text: `Error getting component language progress: ${error.message}`, }, ], isError: true, }; } }
- src/tools/statistics.tool.ts:175-178 (schema)Zod schema defining the input parameters for the tool: projectSlug and componentSlug as required strings.parameters: z.object({ projectSlug: z.string().describe('The slug of the project'), componentSlug: z.string().describe('The slug of the component'), }),
- Supporting service method that implements the core logic: fetches project languages and concurrently retrieves translation statistics for each in the component via Weblate API calls.async getComponentLanguageProgress(projectSlug: string, componentSlug: string) { try { // Get available languages for the project const languages = await this.languagesService.listLanguages(projectSlug); // Get translation statistics for each language const languageProgress = await Promise.all( languages.map(async (language) => { try { const stats = await this.getTranslationStatistics( projectSlug, componentSlug, language.code, ); return { language: language.name, code: language.code, statistics: stats, }; } catch (error) { this.logger.warn( `Failed to get translation stats for ${language.code} in ${componentSlug}`, error, ); return { language: language.name, code: language.code, statistics: null, error: error.message, }; } }), ); return languageProgress; } catch (error) { this.logger.error( `Failed to get component language progress for ${projectSlug}/${componentSlug}`, error, ); throw error; } }
- src/tools/statistics.tool.ts:412-443 (helper)Private helper method that formats the language progress data into a human-readable Markdown string, including progress bars generated by generateProgressBar.private formatComponentLanguageProgress( projectSlug: string, componentSlug: string, progress: any[], ): string { let result = `## 🌐 Language Progress: ${projectSlug}/${componentSlug}\n\n`; progress.forEach((lang: any, index: number) => { if (lang.statistics) { const stats = lang.statistics; const formatPercent = (value: any) => { return typeof value === 'number' ? `${value.toFixed(1)}%` : 'N/A'; }; const progressBar = this.generateProgressBar(stats.translated_percent || 0); result += `**${index + 1}. ${lang.language}** (${lang.code}) ${progressBar} ${formatPercent(stats.translated_percent)} - ✅ Approved: ${formatPercent(stats.approved_percent)} - 📝 Total: ${stats.total || 'N/A'} | Translated: ${stats.translated || 'N/A'} `; } else { result += `**${index + 1}. ${lang.language}** (${lang.code}) - ❌ Error: ${lang.error || 'Unable to load statistics'} `; } }); return result; }
- src/app.module.ts:79-79 (registration)Registers the WeblateStatisticsTool (containing the tool handler) as a NestJS provider in the application module, making the tools available via MCP.WeblateStatisticsTool,