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')}`;
      }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but only states what the tool does without behavioral details. It doesn't disclose whether this is a read-only operation, potential rate limits, authentication needs, or what the statistics include (e.g., counts, percentages).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the purpose without unnecessary words. Every part of the sentence contributes directly to understanding the tool's function.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a read operation with no annotations and no output schema, the description is adequate but incomplete. It specifies the target resource clearly but lacks details on return values, error conditions, or behavioral constraints, leaving gaps for an agent to infer usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents the three parameters. The description adds minimal value by mentioning 'project/component/language combination', which aligns with the parameters but doesn't provide additional syntax or format details beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get statistics') and the target resource ('for a specific translation'), specifying it's for a project/component/language combination. It distinguishes from siblings like getComponentStatistics or getLanguageStatistics by focusing on translation-level stats, though it doesn't explicitly name alternatives.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like getComponentStatistics or getLanguageStatistics. The description implies usage for translation-specific stats but doesn't specify scenarios, prerequisites, or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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