Skip to main content
Glama

add_translations

Add translations for existing terms in a POEditor project without overwriting current content. Specify language and term details to update multilingual content.

Instructions

Add translations for EXISTING terms in a language (does not overwrite). Use this only when terms already exist. If you need to create new terms AND add their translations, prefer using add_terms_with_translations instead. Important: if a term was created with a context, you must provide the same context value to match that term.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idNo
languageYes
itemsYes

Implementation Reference

  • The handler function for the add_translations tool. It processes the input arguments, constructs a payload for multiple translation items (handling singular and plural translations), stringifies it, and calls the POEditor API 'translations/add' endpoint.
    async (args) => {
      const id = requireProjectId(args.project_id ?? null);
      const payload = args.items.map((i) => ({
        term: i.term,
        context: i.context ?? "",
        translation: i.plural ? { plural: i.plural } : { content: i.content, fuzzy: i.fuzzy ? 1 : 0 }
      }));
      const data = JSON.stringify(payload);
      const res = await poeditor("translations/add", { id: String(id), language: args.language, data });
      return { content: [{ type: "text", text: JSON.stringify(res.result ?? {}, null, 2) }] };
    }
  • Zod schema defining the input structure for the add_translations tool (and update_translations). Includes optional project_id, required language code, and array of translation items with term, optional context, content (default empty), optional fuzzy flag, and optional plural forms.
    const TranslationsInput = z.object({
      project_id: z.number().int().positive().optional(),
      language: z.string().min(2),
      items: z.array(z.object({
        term: z.string().min(1),
        context: z.string().optional(),
        content: z.string().default(""),
        fuzzy: z.boolean().optional(),
        plural: z.object({
          one: z.string().optional(),
          few: z.string().optional(),
          many: z.string().optional(),
          other: z.string().optional()
        }).partial().optional()
      })).min(1)
    });
  • src/server.ts:152-167 (registration)
    Registration of the add_translations tool on the MCP server using server.tool(), including name, description, input schema, and inline handler function.
    server.tool(
      "add_translations",
      "Add translations for EXISTING terms in a language (does not overwrite). Use this only when terms already exist. If you need to create new terms AND add their translations, prefer using add_terms_with_translations instead. Important: if a term was created with a context, you must provide the same context value to match that term.",
      TranslationsInput.shape,
      async (args) => {
        const id = requireProjectId(args.project_id ?? null);
        const payload = args.items.map((i) => ({
          term: i.term,
          context: i.context ?? "",
          translation: i.plural ? { plural: i.plural } : { content: i.content, fuzzy: i.fuzzy ? 1 : 0 }
        }));
        const data = JSON.stringify(payload);
        const res = await poeditor("translations/add", { id: String(id), language: args.language, data });
        return { content: [{ type: "text", text: JSON.stringify(res.result ?? {}, null, 2) }] };
      }
    );
  • Helper function used in the handler to resolve or require the project ID from args or environment variable.
    function requireProjectId(argProjectId?: number | null) {
      const id = argProjectId ?? (PROJECT_ID ? Number(PROJECT_ID) : null);
      if (!id) throw new Error("project_id is required (either pass it to the tool or set POEDITOR_PROJECT_ID)");
      return id;
    }

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/ryan-shaw/poeditor-mcp'

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