Skip to main content
Glama
mmntm

Weblate MCP Server

by mmntm

getLanguageStatistics

Retrieve translation statistics for a specific language code across all Weblate projects to monitor progress and identify areas needing attention.

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

  • The @Tool-decorated handler function implementing the core logic for the getLanguageStatistics tool. It fetches statistics from the service, formats them, and returns a structured response or error.
    @Tool({ name: 'getLanguageStatistics', description: 'Get statistics for a specific language across all projects', parameters: z.object({ languageCode: z.string().describe('The language code (e.g., en, es, fr)'), }), }) 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, }; } }
  • 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)'), }),
  • The WeblateStatisticsTool class (containing the getLanguageStatistics handler) is registered as a provider in the root AppModule, making its tools available via MCP.
    WeblateProjectsTool, WeblateComponentsTool, WeblateLanguagesTool, WeblateTranslationsTool, WeblateChangesTool, WeblateStatisticsTool, ],
  • Helper service method that calls the Weblate API to retrieve raw language statistics data, invoked by the tool handler.
    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; } }
  • Private helper method to format the raw statistics 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')}`; }

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