npm.io
0.1.1 • Published 5d ago

@lingo.dev/payloadcms

Licence
Version
0.1.1
Deps
0
Size
23 kB
Vulns
0
Weekly
0

@lingo.dev/payloadcms

Lingo.dev plugin for Payload CMS. It connects your Payload instance to Lingo.dev so your localized collections and globals are translated automatically as you edit them.

Install

pnpm add @lingo.dev/payloadcms

payload is a peer dependency.

Usage

Add the plugin to your Payload config:

import { buildConfig } from "payload";
import { lingo } from "@lingo.dev/payloadcms";

export default buildConfig({
  // ...your collections, globals, localization, etc.
  plugins: [
    lingo({
      webhookUrl: process.env.LINGO_WEBHOOK_URL,
    }),
  ],
});

The plugin does two things:

  • Registers GET /api/lingo/schema. Lingo.dev reads it to decide which fields are translatable (localized text and rich text) so non-prose fields like selects, numbers, and URLs are never sent for translation. Authenticated with the logged-in Payload user session.
  • Pushes content changes to Lingo.dev. When webhookUrl is set and localization is configured, the plugin appends an afterChange hook to every collection and global that notifies Lingo.dev when a document changes in the source locale. Lingo.dev re-reads the document and translates it. The source locale comes from your config's localization.defaultLocale.

Configuration lives in the dashboard

What actually gets translated — which collections, which target locales, which engine — is configured in the Lingo.dev dashboard, not in this plugin. That keeps scope changes out of your codebase: adjust them in the dashboard and they take effect without a redeploy.

webhookUrl is the one value the plugin needs. You get it when you connect Payload in the dashboard; store it as an environment variable. Omit it to register only the schema endpoint and trigger translation manually from the dashboard.

Keywords