getComponentLanguageProgress
Retrieve translation progress statistics for all languages in a Weblate component to monitor localization status and identify areas needing attention.
Instructions
Get translation progress for all languages in a component
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectSlug | Yes | The slug of the project | |
| componentSlug | Yes | The slug of the component |
Implementation Reference
- src/tools/statistics.tool.ts:172-216 (handler)Main handler for the MCP tool 'getComponentLanguageProgress'. Includes @Tool decorator with name, description, Zod input schema, and the async function that delegates to statistics service, formats output, and handles errors.@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 input parameters for the tool: projectSlug and componentSlug.parameters: z.object({ projectSlug: z.string().describe('The slug of the project'), componentSlug: z.string().describe('The slug of the component'), }),
- Core service method implementing the logic to fetch translation progress: lists project languages and retrieves statistics for each in the component.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)Formatter helper that converts language progress data into a formatted Markdown string with progress bars and statistics per language.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)Registration of the WeblateStatisticsTool class (containing the tool handler) as a provider in the NestJS AppModule.WeblateStatisticsTool,