Crayonan

payload plugin ai localization

by Crayonan
Translation
v3
^3.37.0
MIT

Overview

Summary generated from the README

Adds an auto-translate button to configured localized fields when editing a non-default locale in the Payload admin. It fetches the content from the primary locale, sends it to OpenAI for translation, and fills the current locale's field. Requires Payload 3.37 or higher, localization enabled in the config, and an OpenAI API key.

Features

  • Auto-translate button on configured fields in non-primary locales
  • Translates from the default locale to the current locale in one click
  • Per-collection selection of fields that get translation buttons
  • Supports text, textarea and rich text fields while preserving formatting
  • Configurable OpenAI model, defaulting to gpt-4.1-nano
  • Adds a bulk translate REST endpoint to the Payload app

Use cases

  • Speed up creating translated versions of posts and pages for a multi-language site
  • Draft first-pass translations for editors to review in each locale

From the author

AI-powered localization plugin for Payload CMS using OpenAI

Installation

npm i payload-plugin-ai-localization

26

Stars

1

Forks

1

Open Issues

1 years ago

Last Updated

36

Weekly Downloads

v1.0.3

npm Version

50.7 KB

Unpacked Size

2

Dependencies

GitHub stars

260 since Sep 6

Show data
GitHub stars by day (UTC)
DateStars
Dec 5, 202626
Dec 4, 202626
Dec 3, 202626
Dec 2, 202626
Dec 1, 202626
Nov 30, 202626
Nov 29, 202626
Nov 28, 202626
Nov 27, 202626
Nov 26, 202626
Nov 25, 202626
Nov 24, 202626
Nov 23, 202626
Nov 22, 202626
Nov 21, 202626
Nov 20, 202626
Nov 19, 202626
Nov 18, 202626
Nov 17, 202626
Nov 16, 202626
Nov 15, 202626
Nov 14, 202626
Nov 13, 202626
Nov 12, 202626
Nov 11, 202626
Nov 10, 202626
Nov 9, 202626
Nov 8, 202626
Nov 7, 202626
Nov 6, 202626
Nov 5, 202626
Nov 4, 202626
Nov 3, 202626
Nov 2, 202626
Nov 1, 202626
Oct 31, 202626
Oct 30, 202626
Oct 29, 202626
Oct 28, 202626
Oct 27, 202626
Oct 26, 202626
Oct 25, 202626
Oct 24, 202626
Oct 23, 202626
Oct 22, 202626
Oct 21, 202626
Oct 20, 202626
Oct 19, 202626
Oct 18, 202626
Oct 17, 202626
Oct 16, 202626
Oct 15, 202626
Oct 14, 202626
Oct 13, 202626
Oct 12, 202626
Oct 11, 202626
Oct 10, 202626
Oct 9, 202626
Oct 8, 202626
Oct 7, 202626
Oct 6, 202626
Oct 5, 202626
Oct 4, 202626
Oct 3, 202626
Oct 2, 202626
Oct 1, 202626
Sep 30, 202626
Sep 29, 202626
Sep 28, 202626
Sep 27, 202626
Sep 26, 202626
Sep 25, 202626
Sep 24, 202626
Sep 23, 202626
Sep 22, 202626
Sep 21, 202626
Sep 20, 202626
Sep 19, 202626
Sep 18, 202626
Sep 17, 202626
Sep 16, 202626
Sep 15, 202626
Sep 14, 202626
Sep 13, 202626
Sep 12, 202626
Sep 11, 202626
Sep 10, 202626
Sep 9, 202626
Sep 8, 202626
Sep 7, 202626
Sep 6, 202626
npm weekly downloads

20+11 since Sep 6

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 5, 202620
Dec 4, 202623
Dec 3, 202624
Dec 2, 202622
Dec 1, 202629
Nov 30, 202634
Nov 29, 202644
Nov 28, 202644
Nov 27, 202640
Nov 26, 202635
Nov 25, 202650
Nov 24, 202645
Nov 23, 202638
Nov 22, 202632
Nov 21, 202636
Nov 20, 202649
Nov 19, 202654
Nov 18, 202643
Nov 17, 202640
Nov 16, 202644
Nov 15, 202639
Nov 14, 202633
Nov 13, 202621
Nov 12, 202649
Nov 11, 202645
Nov 10, 202651
Nov 9, 202647
Nov 8, 202654
Nov 7, 202656
Nov 6, 202654
Nov 5, 202659
Nov 4, 202662
Nov 3, 202664
Nov 2, 202668
Nov 1, 202666
Oct 31, 202666
Oct 30, 202670
Oct 29, 202632
Oct 28, 202629
Oct 27, 202623
Oct 26, 202619
Oct 25, 202614
Oct 24, 202619
Oct 23, 202613
Oct 22, 202619
Oct 21, 202624
Oct 20, 202624
Oct 19, 202622
Oct 18, 202622
Oct 17, 202617
Oct 16, 202618
Oct 15, 202614
Oct 14, 20269
Oct 13, 202612
Oct 12, 202612
Oct 11, 202616
Oct 10, 202625
Oct 9, 202626
Oct 8, 202624
Oct 7, 202624
Oct 6, 202622
Oct 5, 202623
Oct 4, 202621
Oct 3, 202628
Oct 2, 202673
Oct 1, 202674
Sep 30, 202678
Sep 29, 202690
Sep 28, 202691
Sep 27, 202692
Sep 26, 2026116
Sep 25, 2026148
Sep 24, 2026189
Sep 23, 2026190
Sep 22, 2026178
Sep 21, 2026180
Sep 20, 2026177
Sep 19, 2026136
Sep 18, 202661
Sep 17, 202635
Sep 16, 202633
Sep 15, 202629
Sep 14, 202627
Sep 13, 202627
Sep 12, 202628
Sep 11, 202625
Sep 10, 202610
Sep 9, 20268
Sep 8, 20268
Sep 7, 202610
Sep 6, 20269

Each point is npm's rolling 7-day download count.

Health Score

43/100Fair

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/1000565815-root.svg)](https://payloaddirectory.dev/plugins/1000565815-root)
HTML
<a href="https://payloaddirectory.dev/plugins/1000565815-root"><img src="https://payloaddirectory.dev/badge/1000565815-root.svg" alt="Payload Directory"></a>
Updated Jun 12, 2025Created Jun 12, 2025Published Jun 12, 2025

README

AI Localization Plugin for Payload CMS

A Payload CMS plugin that provides AI-powered content translation using OpenAI, designed to work seamlessly with Payload's built-in localization system.

Features

  • Leverages Existing Localization: Works with the languages you've already configured in your Payload localization settings
  • Context-Aware UI: Adds an "Auto-Translate" button that appears alongside any localized field when you are viewing a non-primary language
  • One-Click Translations: With a single click, the system fetches the content from the document's main language and translates it to the current locale
  • Smart Field Detection: Only shows translation buttons on fields you've configured for translation
  • Multiple Field Types: Supports text, textarea, and rich text fields

Installation

npm install payload-plugin-ai-localization

Configuration

First, ensure your Payload config has localization enabled:

import { buildConfig } from 'payload'
import { aiLocalization } from 'payload-plugin-ai-localization'

export default buildConfig({
  // ... other config
  localization: {
    locales: ['en', 'de', 'fr', 'es'], // Configure your supported locales
    defaultLocale: 'en', // Set your default locale
  },
  plugins: [
    aiLocalization({
      openai: {
        apiKey: process.env.OPENAI_API_KEY, // Your OpenAI API key
        model: 'gpt-4.1-nano', // Optional: specify the model (defaults to gpt-4.1-nano)
      },
      collections: {
        posts: {
          fields: ['title', 'excerpt', 'content'], // Fields that should have auto-translate buttons
        },
        pages: {
          fields: ['title', 'description'],
        },
      },
    }),
  ],
})

Usage

  1. Create or edit a document in your Payload admin panel
  2. Switch to a non-primary language using Payload's built-in language switcher
  3. Click the "Auto-translate from English" button that appears below any configured field
  4. The content will be automatically translated from the primary language to the current locale

Environment Variables

Make sure to set your OpenAI API key in your environment variables of PayloadCMS:

OPENAI_API_KEY=your_openai_api_key_here

How It Works

The plugin integrates with Payload's native localization system by:

  1. Detecting the current locale from Payload's context
  2. Fetching content from the primary locale when you click translate
  3. Using OpenAI to translate the content to the target language
  4. Updating the field in the current locale with the translated content

Supported Field Types

  • text - Single line text fields
  • textarea - Multi-line text fields
  • richText - Rich text editor fields (preserves formatting)

API Endpoints

The plugin adds these endpoints to your Payload app:

  • POST /api/ai-localization/translate-bulk - Translates content between locales

License

MIT

Contributing

Contributions are welcome! Please read the contributing guidelines before submitting PRs.

Support

For issues and questions:

  • Create an issue on GitHub
  • Check the Payload CMS Discord community
  • Review the documentation

Note: This plugin requires Payload CMS v3.37.0 or higher and an OpenAI API key.

Similar plugins