Skip to main content
Glama

localizationFindMissing

Identify missing translations for a specific language in localization files to ensure consistent multilingual support and improve language coverage.

Instructions

查找有Key值但缺少特定語言翻譯的項目

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYes
languageYes
limitNo

Implementation Reference

  • The core handler function `findMissingTranslations` that scans the CSV file for entries with a Key but missing translation in the specified language. Filters records where the language field is empty/null/undefined/whitespace.
    static async findMissingTranslations(filePath: string, language: string, limit: number = 50): Promise<SearchResult> { try { if (!language) { throw new Error('必須指定要檢查的語言'); } const records = await this.getCSVData(filePath); // 尋找指定語言翻譯為空的項目 const missingEntries = records.filter(entry => { // 確保有Key且該語言的翻譯為空 return entry.Key && (entry[language] === undefined || entry[language] === null || entry[language].trim() === ''); }); // 限制返回數量 const limitedResults = missingEntries.slice(0, limit); return { totalResults: missingEntries.length, entries: limitedResults }; } catch (error) { console.error(`搜尋缺少翻譯的項目失敗: ${error instanceof Error ? error.message : '未知錯誤'}`); throw error; } }
  • main.ts:434-453 (registration)
    Tool registration using server.tool(), including inline handler wrapper that delegates to LocalizationTool.findMissingTranslations and formats the MCP response.
    server.tool("localizationFindMissing", "查找有Key值但缺少特定語言翻譯的項目", { filePath: z.string(), language: z.string(), limit: z.number().optional() }, async ({ filePath, language, limit = 50 }) => { try { const results = await LocalizationTool.findMissingTranslations(filePath, language, limit); return { content: [{ type: "text", text: JSON.stringify(results, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `搜尋缺少翻譯項目失敗: ${error instanceof Error ? error.message : "未知錯誤"}` }] }; } } );
  • Zod input schema defining parameters: filePath (string), language (string), limit (number, optional).
    { filePath: z.string(), language: z.string(), limit: z.number().optional() },
  • TypeScript interface for the output structure returned by the handler: totalResults and entries array.
    export interface SearchResult { totalResults: number; entries: LocalizationEntry[]; }

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/GonTwVn/GonMCPtool'

If you have feedback or need assistance with the MCP directory API, please join our Discord server