Skip to main content
Glama
mmntm

Weblate MCP Server

by mmntm

getTranslationStatistics

Retrieve detailed statistics for a specific translation project, component, and language combination using the Weblate MCP Server. Analyze translation progress and accuracy efficiently.

Instructions

Get statistics for a specific translation (project/component/language combination)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
componentSlugYesThe slug of the component
languageCodeYesThe language code (e.g., en, es, fr)
projectSlugYesThe slug of the project

Implementation Reference

  • Main MCP tool handler: decorated with @Tool, validates input, calls service, formats response with error handling.
    @Tool({ name: 'getTranslationStatistics', description: 'Get statistics for a specific translation (project/component/language combination)', parameters: z.object({ projectSlug: z.string().describe('The slug of the project'), componentSlug: z.string().describe('The slug of the component'), languageCode: z.string().describe('The language code (e.g., en, es, fr)'), }), }) async getTranslationStatistics({ projectSlug, componentSlug, languageCode, }: { projectSlug: string; componentSlug: string; languageCode: string; }) { try { const stats = await this.statisticsService.getTranslationStatistics( projectSlug, componentSlug, languageCode, ); return { content: [ { type: 'text', text: this.formatTranslationStatistics(projectSlug, componentSlug, languageCode, stats), }, ], }; } catch (error) { this.logger.error( `Failed to get translation statistics for ${projectSlug}/${componentSlug}/${languageCode}`, error, ); return { content: [ { type: 'text', text: `Error getting translation statistics: ${error.message}`, }, ], isError: true, }; } }
  • Zod input schema defining parameters for the tool.
    parameters: z.object({ projectSlug: z.string().describe('The slug of the project'), componentSlug: z.string().describe('The slug of the component'), languageCode: z.string().describe('The language code (e.g., en, es, fr)'), }),
  • Service helper: Calls Weblate API to retrieve translation statistics for project/component/language.
    async getTranslationStatistics( projectSlug: string, componentSlug: string, languageCode: string, ) { try { const response = await translationsStatisticsRetrieve({ client: this.clientService.getClient(), path: { component__project__slug: projectSlug, component__slug: componentSlug, language__code: languageCode, }, query: { format: 'json' }, }); if (response.error) { throw new Error(`Failed to get translation statistics: ${response.error}`); } return response.data; } catch (error) { this.logger.error( `Failed to get translation statistics for ${projectSlug}/${componentSlug}/${languageCode}`, error, ); throw error; } }
  • Helper function to format the statistics into a markdown string for the tool response.
    private formatTranslationStatistics( projectSlug: string, componentSlug: string, 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 `## 📊 Translation Statistics **Translation:** ${projectSlug}/${componentSlug}/${languageCode} **Progress:** - 🎯 Translated: ${formatPercent(getStatValue('translated_percent'))} - ✅ Approved: ${formatPercent(getStatValue('approved_percent'))} - 🔍 Needs Review: ${formatPercent(getStatValue('readonly_percent'))} - ❌ Untranslated: ${formatPercent(getStatValue('nottranslated_percent'))} **String Details:** - 📝 Total Strings: ${getStatValue('total')} - ✅ Translated: ${getStatValue('translated')} - 🎯 Approved: ${getStatValue('approved')} - ❌ Untranslated: ${getStatValue('nottranslated')} - 🔍 Readonly: ${getStatValue('readonly')} **Quality Metrics:** - ⚠️ Failing Checks: ${getStatValue('failing_percent', '0')}% - 💡 Suggestions: ${getStatValue('suggestions')} - 💬 Comments: ${getStatValue('comments')}`; }
  • AppModule registers WeblateStatisticsTool (containing the handler) and WeblateStatisticsService (helper) as providers, enabling the tool.
    providers: [ WeblateClientService, WeblateProjectsService, WeblateComponentsService, WeblateLanguagesService, WeblateTranslationsService, WeblateChangesService, WeblateApiService, WeblateStatisticsService, WeblateProjectsTool, WeblateComponentsTool, WeblateLanguagesTool, WeblateTranslationsTool, WeblateChangesTool, 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