Skip to main content
Glama
mmntm

Weblate MCP Server

by mmntm

getTranslationStatistics

Retrieve statistics for a specific translation project, component, and language combination to monitor translation progress and status.

Instructions

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

Input Schema

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

Implementation Reference

  • The @Tool-decorated handler function implementing the core logic for getTranslationStatistics, which fetches data from the service and formats the output.
    @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 schema defining the input parameters for the getTranslationStatistics 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)'), }),
  • Registration of WeblateStatisticsTool (containing the getTranslationStatistics handler) in the AppModule providers.
    WeblateProjectsTool, WeblateComponentsTool, WeblateLanguagesTool, WeblateTranslationsTool, WeblateChangesTool, WeblateStatisticsTool, ],
  • Helper service method that retrieves translation statistics from the Weblate API via translationsStatisticsRetrieve.
    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 method to format the translation statistics into a readable markdown string.
    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')}`; }

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