compile_mo
Compile .mo files from .po files for Webasyst framework localization, enabling AI-assisted development of multilingual applications.
Instructions
Скомпилировать .mo из .po
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| app_id | Yes | ||
| locale | No |
Implementation Reference
- webasyst-mcp.js:1313-1324 (handler)The main execution logic for the 'compile_mo' tool: locates the PO file in the app's locale directory, compiles it to MO using the system's msgfmt command, and returns success message with path.async function compileMoTool({ app_id, locale = 'ru_RU' }) { const rootPath = await findWebasystRoot(); const poPath = path.join(rootPath, 'wa-apps', app_id, 'locale', locale, 'LC_MESSAGES', `${app_id}.po`); const moPath = path.join(rootPath, 'wa-apps', app_id, 'locale', locale, 'LC_MESSAGES', `${app_id}.mo`); if (!(await fileExists(poPath))) throw new Error('PO файл не найден, сначала сгенерируйте шаблон'); try { execSync(`msgfmt "${poPath}" -o "${moPath}"`); return { content: [{ type: 'text', text: `MO скомпилирован: ${moPath}` }] }; } catch (e) { throw new Error('Не удалось выполнить msgfmt. Установите gettext.'); } }
- webasyst-mcp.js:1740-1740 (registration)Registration of the 'compile_mo' tool in the MCP server's tool list, including description and input schema (requires app_id, optional locale).{ name: 'compile_mo', description: 'Скомпилировать .mo из .po', inputSchema: { type: 'object', properties: { app_id: { type: 'string' }, locale: { type: 'string' } }, required: ['app_id'] } },
- webasyst-mcp.js:1802-1802 (registration)Dispatch handler in the CallToolRequestSchema that maps the tool name to the compileMoTool function.case 'compile_mo': return await compileMoTool(args);
- webasyst-mcp.js:1740-1740 (schema)Input schema validation: object with 'app_id' (required string) and optional 'locale' (defaults to 'ru_RU').{ name: 'compile_mo', description: 'Скомпилировать .mo из .po', inputSchema: { type: 'object', properties: { app_id: { type: 'string' }, locale: { type: 'string' } }, required: ['app_id'] } },
- webasyst-mcp.js:31-45 (helper)Helper function used by compileMoTool to locate the Webasyst root directory by searching upwards for index.php and wa-system.async function findWebasystRoot(startCwd = process.cwd()) { let currentDir = startCwd; while (currentDir !== '/') { const indexPath = path.join(currentDir, 'index.php'); const systemPath = path.join(currentDir, 'wa-system'); try { await fs.access(indexPath); await fs.access(systemPath); return currentDir; } catch { currentDir = path.dirname(currentDir); } } throw new Error('Корневая директория Webasyst не найдена'); }