Skip to main content
Glama

localizationFindMissing

Identify translation keys that exist but lack specific language translations in localization files to maintain multilingual consistency.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYes
languageYes
limitNo

Implementation Reference

  • Core implementation of findMissingTranslations: loads CSV data via cache, filters entries that have a Key but empty/missing value in the specified language, applies limit, returns SearchResult with total and limited entries.
    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-452 (registration)
    Registers the 'localizationFindMissing' tool on the MCP server, defines input schema (filePath, language, optional limit), provides inline handler that calls LocalizationTool.findMissingTranslations and formats JSON 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 for the tool: filePath (string), language (string), limit (number, optional).
    { filePath: z.string(), language: z.string(), limit: z.number().optional() },
  • TypeScript interface defining structure of localization entries (CSV rows): Key and language fields.
    export interface LocalizationEntry { Key: string; 'zh-TW': string; 'zh-CN': string; en: string; [key: string]: string; // 其他可能的語言欄位 }
  • Output interface SearchResult used by findMissingTranslations: totalResults (number) 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