Skip to main content
Glama

localizationExportJson

Export translations for a specific language into a JSON format, enabling efficient localization management for projects using the GonMCPtool MCP server.

Instructions

將特定語言的翻譯導出為JSON格式

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYes
languageYes

Implementation Reference

  • Core handler function that reads the CSV localization file, extracts translations for the specified language into a key-value object, and returns a formatted JSON string.
    static async exportLanguageAsJson(filePath: string, language: string): Promise<string> { try { const records = await this.getCSVData(filePath); // 創建Key-Value的映射 const langData: Record<string, string> = {}; for (const entry of records) { if (entry.Key && entry[language]) { langData[entry.Key] = entry[language]; } } return JSON.stringify(langData, null, 2); } catch (error) { console.error(`匯出語言資料失敗: ${error instanceof Error ? error.message : '未知錯誤'}`); throw error; } }
  • Zod input schema defining parameters: filePath (string) and language (string).
    { filePath: z.string(), language: z.string() },
  • main.ts:416-431 (registration)
    Tool registration with name, description, input schema, and thin async handler that calls the core LocalizationTool.exportLanguageAsJson method and formats the MCP response.
    server.tool("localizationExportJson", "將特定語言的翻譯導出為JSON格式", { filePath: z.string(), language: z.string() }, async ({ filePath, language }) => { try { const result = await LocalizationTool.exportLanguageAsJson(filePath, language); return { content: [{ type: "text", text: result }] }; } catch (error) { return { content: [{ type: "text", text: `匯出失敗: ${error instanceof Error ? error.message : "未知錯誤"}` }] }; } } );

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