Skip to main content
Glama
mmntm

Weblate MCP Server

by mmntm

getComponentLanguageProgress

Retrieve translation progress statistics for all languages in a specific component within a Weblate project using project and component slugs.

Instructions

Get translation progress for all languages in a component

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
componentSlugYesThe slug of the component
projectSlugYesThe slug of the project

Implementation Reference

  • The primary handler function for the 'getComponentLanguageProgress' MCP tool. It validates inputs via Zod schema, delegates to the statistics service for data retrieval, formats the response using a private method, and returns structured content or error.
    @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, }; } }
  • Zod schema defining the input parameters for the tool: projectSlug and componentSlug as required strings.
    parameters: z.object({ projectSlug: z.string().describe('The slug of the project'), componentSlug: z.string().describe('The slug of the component'), }),
  • Supporting service method that implements the core logic: fetches project languages and concurrently retrieves translation statistics for each in the component via Weblate API calls.
    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; } }
  • Private helper method that formats the language progress data into a human-readable Markdown string, including progress bars generated by generateProgressBar.
    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; }
  • Registers the WeblateStatisticsTool (containing the tool handler) as a NestJS provider in the application module, making the tools available via MCP.
    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