Skip to main content
Glama

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
NameRequiredDescriptionDefault
app_idYes
localeNo

Implementation Reference

  • 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.'); } }
  • 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'] } },
  • Dispatch handler in the CallToolRequestSchema that maps the tool name to the compileMoTool function.
    case 'compile_mo': return await compileMoTool(args);
  • 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'] } },
  • 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 не найдена'); }

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/emmy-design/webasyst-mcp'

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