getLanguageStatistics
Generate language-specific statistics across all translation projects in Weblate MCP Server by providing the target language code for comprehensive analysis.
Instructions
Get statistics for a specific language across all projects
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| languageCode | Yes | The language code (e.g., en, es, fr) |
Implementation Reference
- src/tools/statistics.tool.ts:225-249 (handler)Primary MCP tool handler for getLanguageStatistics. Calls the statistics service, formats the output using formatLanguageStatistics, and returns MCP-formatted content or error.async getLanguageStatistics({ languageCode }: { languageCode: string }) { try { const stats = await this.statisticsService.getLanguageStatistics(languageCode); return { content: [ { type: 'text', text: this.formatLanguageStatistics(languageCode, stats), }, ], }; } catch (error) { this.logger.error(`Failed to get language statistics for ${languageCode}`, error); return { content: [ { type: 'text', text: `Error getting language statistics: ${error.message}`, }, ], isError: true, }; } }
- Service method that performs the actual API call to retrieve language statistics from Weblate using languagesStatisticsRetrieve.async getLanguageStatistics(languageCode: string) { try { const response = await languagesStatisticsRetrieve({ client: this.clientService.getClient(), path: { code: languageCode }, query: { format: 'json' }, }); if (response.error) { throw new Error(`Failed to get language statistics: ${response.error}`); } return response.data; } catch (error) { this.logger.error(`Failed to get language statistics for ${languageCode}`, error); throw error; } }
- src/tools/statistics.tool.ts:221-223 (schema)Zod schema defining the input parameter 'languageCode' for the tool.parameters: z.object({ languageCode: z.string().describe('The language code (e.g., en, es, fr)'), }),
- src/tools/statistics.tool.ts:445-471 (helper)Helper method to format the raw statistics data into a human-readable markdown string for the tool response.private formatLanguageStatistics(languageCode: string, stats: any): string { const getStatValue = (key: string, defaultValue = 'N/A') => { return stats?.[key] !== undefined ? stats[key] : defaultValue; }; const formatPercent = (value: any) => { return typeof value === 'number' ? `${value.toFixed(1)}%` : 'N/A'; }; return `## 🌐 Language Statistics: ${stats?.name || languageCode} **Language Details:** - 📛 Name: ${getStatValue('name')} - 🔤 Code: ${getStatValue('code')} - 📍 Direction: ${getStatValue('direction', 'ltr')} **Overall Progress:** - 🎯 Translated: ${formatPercent(getStatValue('translated_percent'))} - ✅ Approved: ${formatPercent(getStatValue('approved_percent'))} - ❌ Untranslated: ${formatPercent(getStatValue('nottranslated_percent'))} **String Counts:** - 📝 Total: ${getStatValue('total')} - ✅ Translated: ${getStatValue('translated')} - 🎯 Approved: ${getStatValue('approved')} - ❌ Untranslated: ${getStatValue('nottranslated')}`; }
- src/app.module.ts:79-79 (registration)Registration of the WeblateStatisticsTool class in the AppModule providers array, making the tools available.WeblateStatisticsTool,