Skip to main content
Glama
mmntm

Weblate MCP Server

by mmntm

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
NameRequiredDescriptionDefault
languageCodeYesThe language code (e.g., en, es, fr)

Implementation Reference

  • 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; } }
  • 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)'), }),
  • 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')}`; }
  • Registration of the WeblateStatisticsTool class in the AppModule providers array, making the tools available.
    WeblateStatisticsTool,

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/mmntm/weblate-mcp'

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