AI Translator: a WordPress plugin that translates a site with AI models (Claude, ChatGPT) or DeepL, once per content, never at page load.
  • PHP 84.2%
  • JavaScript 10.3%
  • CSS 4.1%
  • Shell 1.4%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-11-23 01:08:52 +01:00
assets Tabs per subject instead of Settings (Languages and contents, AI API, Language switcher), each saving its own settings; half-cost deferred processing beside the caps; the prompt beside the site's instructions; the switcher block's settings in the editor, a shortcode generator, the floating switcher's own look, TranslatePress's switcher blocks known to the editor and replaceable; a dashboard with coloured states, the API's state, costs against caps, an interactive chart; structured log lines 2026-11-23 01:08:52 +01:00
blocks Tabs per subject instead of Settings (Languages and contents, AI API, Language switcher), each saving its own settings; half-cost deferred processing beside the caps; the prompt beside the site's instructions; the switcher block's settings in the editor, a shortcode generator, the floating switcher's own look, TranslatePress's switcher blocks known to the editor and replaceable; a dashboard with coloured states, the API's state, costs against caps, an interactive chart; structured log lines 2026-11-23 01:08:52 +01:00
languages Tabs per subject instead of Settings (Languages and contents, AI API, Language switcher), each saving its own settings; half-cost deferred processing beside the caps; the prompt beside the site's instructions; the switcher block's settings in the editor, a shortcode generator, the floating switcher's own look, TranslatePress's switcher blocks known to the editor and replaceable; a dashboard with coloured states, the API's state, costs against caps, an interactive chart; structured log lines 2026-11-23 01:08:52 +01:00
src Tabs per subject instead of Settings (Languages and contents, AI API, Language switcher), each saving its own settings; half-cost deferred processing beside the caps; the prompt beside the site's instructions; the switcher block's settings in the editor, a shortcode generator, the floating switcher's own look, TranslatePress's switcher blocks known to the editor and replaceable; a dashboard with coloured states, the API's state, costs against caps, an interactive chart; structured log lines 2026-11-23 01:08:52 +01:00
tests Tabs per subject instead of Settings (Languages and contents, AI API, Language switcher), each saving its own settings; half-cost deferred processing beside the caps; the prompt beside the site's instructions; the switcher block's settings in the editor, a shortcode generator, the floating switcher's own look, TranslatePress's switcher blocks known to the editor and replaceable; a dashboard with coloured states, the API's state, costs against caps, an interactive chart; structured log lines 2026-11-23 01:08:52 +01:00
.gitignore Add the translation core: segments, fingerprints, alignment, assembly, checks, addresses 2026-11-22 01:36:12 +01:00
CHANGELOG.md Tabs per subject instead of Settings (Languages and contents, AI API, Language switcher), each saving its own settings; half-cost deferred processing beside the caps; the prompt beside the site's instructions; the switcher block's settings in the editor, a shortcode generator, the floating switcher's own look, TranslatePress's switcher blocks known to the editor and replaceable; a dashboard with coloured states, the API's state, costs against caps, an interactive chart; structured log lines 2026-11-23 01:08:52 +01:00
CLAUDE.md Tabs per subject instead of Settings (Languages and contents, AI API, Language switcher), each saving its own settings; half-cost deferred processing beside the caps; the prompt beside the site's instructions; the switcher block's settings in the editor, a shortcode generator, the floating switcher's own look, TranslatePress's switcher blocks known to the editor and replaceable; a dashboard with coloured states, the API's state, costs against caps, an interactive chart; structured log lines 2026-11-23 01:08:52 +01:00
LICENSE Add the translation core: segments, fingerprints, alignment, assembly, checks, addresses 2026-11-22 01:36:12 +01:00
lrob-ai-translator.php Tabs per subject instead of Settings (Languages and contents, AI API, Language switcher), each saving its own settings; half-cost deferred processing beside the caps; the prompt beside the site's instructions; the switcher block's settings in the editor, a shortcode generator, the floating switcher's own look, TranslatePress's switcher blocks known to the editor and replaceable; a dashboard with coloured states, the API's state, costs against caps, an interactive chart; structured log lines 2026-11-23 01:08:52 +01:00
publish.sh Administration: a dashboard first, the same tabs on every screen, full-contrast text, settings in sections with Advanced folded, one line above the list, Migration says what it supports; trial builds never published 2026-11-23 00:36:23 +01:00
README.md Tabs per subject instead of Settings (Languages and contents, AI API, Language switcher), each saving its own settings; half-cost deferred processing beside the caps; the prompt beside the site's instructions; the switcher block's settings in the editor, a shortcode generator, the floating switcher's own look, TranslatePress's switcher blocks known to the editor and replaceable; a dashboard with coloured states, the API's state, costs against caps, an interactive chart; structured log lines 2026-11-23 01:08:52 +01:00
release.sh Administration: a dashboard first, the same tabs on every screen, full-contrast text, settings in sections with Advanced folded, one line above the list, Migration says what it supports; trial builds never published 2026-11-23 00:36:23 +01:00
uninstall.php 0.5.0: a post can be written in another language than the main one, and is translated into the main one too 2026-11-23 00:07:03 +01:00

LRob - AI Translator

Your WordPress site in several languages, translated by AI with the context of each page, without slowing it down. Write in your language; the plugin translates each page once, in the background, with Claude (Anthropic), and serves it at its own address in every language you choose.

Documentation: the wiki (installation, getting started, modes and costs, the block editor, addresses and SEO, the language switcher, page caches, moving from TranslatePress, developers, troubleshooting).

Why

  • Write each page in the language you want. An article in English on a French site, a page in German on an English one: choose the language a page is written in, and it is translated into every other language of your site, your main language included. Few translation plugins can do this.
  • Translations that read well. Each page is translated as a whole document, not sentence by sentence: the model sees the title, the headings and the paragraphs around what it translates. Names of people, brands and products stay as they are, and the instructions you give about your site (what it is about, who reads it, its tone) are followed.
  • A fast site. Nothing is translated while a page is served: a visitor, or a bot, never triggers a translation and never waits for one. A translated page costs a few indexed queries, none with a persistent object cache, and nothing at all behind a page cache.
  • Small bills. When you edit a page, only what changed is translated again, with just enough context. Long jobs can go in deferred batches at half price, if you choose (back within the hour instead of at once). Daily and monthly caps stop the spending where you want (5 and 50 to start with), automatic translation can be switched off in one click, and every call and its estimated cost is in the log.
  • Search engines see each language. Every translated page has its own address (/en/…, with translated slugs), its <html lang>, its canonical address, hreflang links to the other languages with x-default on your main language, and a place in the sitemap. Its title, description and structured data are in its own language too.
  • You stay in control. Correct any translation by hand: your correction is never overwritten. Exclude a page, or a part of a page, from translation.

What it works with

Made for the block editor. Works with content written in the block editor or in the classic editor, with block themes and classic themes.

Compatible with Rank Math: titles, descriptions, social texts, breadcrumbs, canonical addresses, structured data and sitemaps in each language.

Pages made with a page builder (Elementor, Divi, Avada, WPBakery) are shown in the compatible mode: the builder shows the page as usual, and each of its texts is replaced by its translation just before the page is sent. The translation is still made once, from the page as it is saved, with the whole page as context: for Elementor, from the copy of its texts it keeps in the post content, plus the texts of its data that the copy lacks; its headers and footers are translated too. A text shown that matches no translation stays in the original language, and the translation editor lists the texts visitors last saw untranslated. Media per language are not offered in this mode. Choose the mode for the whole site in Languages and contents → Contents → Page builders, or for one page in its translation editor.

With WPBakery, Divi and Avada, the texts kept in their elements' settings (a heading, a button's text, a tab's title) are translated with the page, as well as the texts between their shortcodes. Other shortcodes can declare their text attributes (see For developers).

With WooCommerce, when products are translated: product names, descriptions and short descriptions, categories and tags, the attributes' values (colour, size), and the names and descriptions of variations, also in the cart and at checkout.

Example

Your site is in French. You add English and German.

  • You write Pourquoi l'hébergement compte at /pourquoi-hebergement/ and publish it.
  • Ten minutes later (the delay is yours to set, and nothing happens while someone has the page open in the editor), the plugin sends it to Claude, once per language.
  • /en/why-hosting-matters/ and /de/warum-hosting-wichtig-ist/ are online, linked to each other for search engines, and reachable from the language switcher.
  • You fix a typo in one paragraph: only that paragraph is translated again, for a fraction of a cent.

Installation

  1. Download lrob-ai-translator-<version>.zip from the releases of the repository.
  2. In WordPress: Plugins → Add New → Upload Plugin, choose the zip, activate.
  3. Open AI Translator: a guided setup takes you through your languages, your Anthropic API key, what is translated, your site's instructions and the language switcher.
  4. Translate the content you already have (an estimate of the cost is shown first).
  5. Turn on Show the translated pages on the site on the dashboard, and place the Language switcher block in your header.

Updates then appear in Dashboard → Updates like any other plugin. If the repository is private, add a read token to wp-config.php:

define( 'LROB_AI_TRANSLATOR_UPDATE_TOKEN', 'your-read-only-token' );

Your API key

Each site uses its own Anthropic API key, from the Claude Console. The safest place for it is wp-config.php:

define( 'LROB_AI_TRANSLATOR_API_KEY', 'sk-ant-...' );

The settings then say that the key comes from this constant, and can still test it. You can also type it in the settings: it is then stored encrypted with your site's secret keys. It is never shown again, never sent to the browser and never written to the log.

We recommend a workspace for the site in the Claude Console, with a monthly spend limit: a second safety net behind the plugin's own caps.

A real cron

Translations run on WP-Cron. On a site with little traffic, or to keep visitors' requests completely free of it, use a system cron:

define( 'DISABLE_WP_CRON', true ); // in wp-config.php
* * * * * php /path/to/site/wp-cron.php >/dev/null 2>&1

How it works

  1. When. Saving a published post, page, category, menu or template part puts it in the queue, after a delay. Content that existed before the plugin is listed as not translated and is translated when you ask, after an estimate. A daily pass catches content changed outside the editor.
  2. What is sent. The content is cut into segments: a paragraph, a heading, a list item, a caption, a button, an image's alternative text, a menu label. Each segment has a fingerprint. Only the segments whose fingerprint is new are translated. The model receives the page as context, and answers with the requested segments only, in a JSON format that is checked: every tag, link and attribute must be the source's, so nothing can be added to your pages.
  3. When a page changes, you choose, in the settings:
    • Translate the whole page again, every time;
    • Balanced (default): what changed, with its whole section when most of the section changed, and the whole page when most of the page changed;
    • Token saver: what changed only, sent in batches at half price, usually within the hour.
  4. Costs. The rules and the page are sent first, so that they are read from Anthropic's prompt cache by the next request: a second language costs little more than its translated text. Caps per day and per month stop the queue; a confirmation is asked before any large job.
  5. Serving. The translated texts are stored in the plugin's tables and handed to WordPress through its own filters: your theme, blocks and archives show them as if they had been written that way. Texts of your theme and plugins come from their own translation files, in the language of the page.

For a typical 1,500-word article, the first translation into one language costs about $0.03 with Claude Sonnet 5.5 (half of it in batches), and about $0.002 with Claude Haiku 5.5. Correcting one sentence afterwards costs about 15% of that in Balanced mode.

What is not translated

  • The administration.
  • Code, scripts and styles; addresses, e-mail addresses, numbers and shortcodes on their own.
  • Anything you mark: add the class notranslate to a block (Advanced → Additional CSS class), or translate="no" to an element. Exclude a whole page from the Translations screen.
  • The addresses you list in Languages and contents → Contents → Addresses not translated (/account/ covers that page and every address under it). They are never read nor sent; under a language's prefix they show as they are, with nothing said to search engines.
  • Sensitive data: a paragraph or field holding a payment card number, an IBAN, a password written out, or an access key or token stays as it is. Values typed in forms are never read. Each request is checked once more before it leaves the site.
  • What a logged-in visitor sees: the plugin translates the content as saved, never a page as displayed to someone.
  • Texts written directly into a classic (PHP) theme's templates without WordPress's translation functions. A block theme's templates, parts and patterns are translated, from the site editor or from the theme's files.

Addresses

The main language stays at the root (/pourquoi-hebergement/); every other language lives under its prefix (/en/). Each part of an address is translated: /hebergement/tarifs/ becomes /en/hosting/pricing/. A new page gets its translated slug once, with its first translation, and keeps it. If you change it, the old address redirects to the new one.

Changing one page's address: in its translation editor, the Address field holds its translated slug for that language.

Keeping addresses you already have (from another plugin, or decided by hand): in AI Translator → Migration, Keep your existing addresses takes a file, one address per line (language, address in the main language, translated address), compares it with the addresses the plugin will serve, and imposes it: those slugs are never translated again. The same from the command line:

wp lrob-ai-translator addresses table.tsv --columns=1,2,3            # compare, writes nothing
wp lrob-ai-translator addresses table.tsv --columns=1,2,3 --impose   # impose, then compare

A page that is not translated yet stays outside the sitemap, and you choose what its address does: show the original with a short message (canonical address: the original), send to the original page (temporary redirection), or answer not found (404).

Moving from TranslatePress

Migration supported from: TranslatePress. Another translation plugin (WPML, Polylang, Weglot…) can stay active beside it while you prepare, but its languages and addresses are not taken over; keep your existing addresses with a file in AI Translator → Migration.

The plugin reads TranslatePress's settings and translated slugs, so that no address changes:

  1. Install LRob - AI Translator while TranslatePress is still active. As long as another translation plugin (TranslatePress, WPML, Polylang, Weglot…) is active, nothing of LRob - AI Translator reaches your visitors' pages: no address rule, no hreflang, no sitemap, no switcher. It only prepares its translations.
  2. List the addresses that must never be translated (a customer area) in Languages and contents → Contents → Addresses not translated.
  3. AI Translator → Migration → Simulate: nothing is written. You see the languages read from TranslatePress, every address it serves and the address parts that will be imposed, the contents to translate and those set aside, the estimated cost, and the addresses that would change (none expected). Then Apply: the languages are set and the addresses imposed. TranslatePress itself is not changed. The same from the command line: wp lrob-ai-translator switch (simulates), --apply.
  4. Translate your content (Translations → Translate everything not translated, or wp lrob-ai-translator translate --all, --dry-run for the estimate only, --failed for the failed ones only), and check a few pages through their preview links.
  5. Simulate once more: still no address that would change. Then deactivate TranslatePress and turn on Show the translated pages on the site. The TranslatePress language switcher blocks and shortcodes you placed keep working; Migration then offers to turn its blocks into this plugin's Language switcher block, whose settings are in the block editor.

To go back, deactivate LRob - AI Translator and reactivate TranslatePress: its data was never touched.

Settings

AI Translator has one tab per subject (each setting has a ? that tells why it is there):

  • Dashboard: the two switches (Translate automatically, Show the translated pages on the site), whether the AI API is ready, each language's progress, today's and this month's costs against your caps, a chart of the last 7, 30 or 90 days, the queue, the latest translations and errors.
  • Translations: every content with its languages; translate, review, exclude, one by one or in bulk.
  • Languages and contents: the main language and the translated ones (address prefix, hreflang code, flag, the order the queue follows); the types of content, page builders, addresses not translated and what a page not translated yet shows; your site's instructions (what it is about, who reads it, its tone, the names to keep as they are) and the prompt itself; what is translated again when a page changes, the delay after saving, the page caches purged. Translate everything again applies new instructions to what is already translated; your corrections by hand are kept.
  • AI API: the API key, the model (the list comes from Anthropic and updates itself), the prices used for the estimates (your invoice is Anthropic's), Halve the cost (deferred processing), the estimated cost of a typical page, caps per day and per month, the amount above which a confirmation is asked.
  • Language switcher: its default look, a shortcode generator, and a floating switcher in a corner of every page (off by default) with its own look. The Language switcher block has all its settings in the block editor's side panel.
  • Migration and Log (every call with its tokens and cost, the totals per day, how long the log is kept).

Correcting a translation

Translate the page (in the admin bar of any page, in the Translations list, or in the Languages panel of the block editor) shows every text of the page beside its original, block by block, with its bold, italics and links, in the language shown at the top with its flag (switch to another from there). Correct a sentence, and your correction is kept and never overwritten. The formatting bar offers the original's own formatting (bold, italics, a link, a highlight…): move it to other words, or take it off (Ctrl+B, Ctrl+I). Each link shows where it leads in the language: a page of your site goes to its translated address by itself, and a link to another site can lead elsewhere for this language. The header, footer and menus are reached from the same screen. Under each text, Translate again with an instruction ("shorter", "more formal") and Propose variants (three to choose from) ask the model about that text alone, with the page as context: the cost shows before anything is sent, and the one you choose is kept as your correction. A block with an image, a video or a link can show another one in a language; if the original's changes later, your choice stays, marked to review. Blocks are added, removed or moved in the original only.

A page written in another language

An article written in English on a French site: in the Languages panel of the block editor, choose Written in → English. It shows as written at its English address (/en/…), and it is translated into every other language of the site, French included, which its main address (/…, its slug unchanged) shows.

The language switcher

Add the Language switcher block to your header (or the [lrob_ai_translator_switcher] shortcode). It shows the name, the short name (EN) or both, with or without the flag, or the flag alone, in a line or as a drop-down menu. Choose it block by block in the block editor's side panel (with a preview of your languages), or for the whole site in AI Translator → Language switcher, which also writes the shortcode for you. A floating switcher can also sit in a corner of every page, with its own look, in the colours of your theme, at the distance from the edges you set (to leave room for a chat button).

For developers

The full list, with examples: For developers in the wiki.

// Languages of the site, the main one first: locale => [prefix, hreflang, name, default].
lrob_ai_translator_languages();
lrob_ai_translator_default_language(); // fr_FR
lrob_ai_translator_current_language(); // en_US on /en/…
// The language a post is written in.
lrob_ai_translator_post_language( $post_id );   // fr_FR, or en_US for a post written in English
// A post's public address in each language it can be read in: locale => URL.
lrob_ai_translator_post_translations( $post_id );

Filters:

  • lrob_ai_translator_skip_request (bool): a plugin that serves its own pages in each language leaves the request alone.
  • lrob_ai_translator_alternates (array locale => URL): the addresses of the current page in each language, for the switcher and hreflang.
  • lrob_ai_translator_skip_object (bool, $type, $id): keep an object out of translation.
  • lrob_ai_translator_meta_keys (array, $post): post meta fields translated with the post.
  • lrob_ai_translator_block_attributes (array block name => attribute names): text attributes of dynamic blocks.
  • lrob_ai_translator_taxonomies (array): taxonomies translated.
  • lrob_ai_translator_shortcode_attributes (array shortcode name => attribute names): the text attributes of shortcodes, written in plain text ('my_button' => array( 'label' )).
  • lrob_ai_translator_post_fields (array field => text, $post): other texts translated with a post, in its context (WooCommerce variations use it).
  • lrob_ai_translator_builder_types (array): a page builder's own kinds of content (headers, footers, sections), translated and applied to every page in the compatible mode.

Action:

  • lrob_ai_translator_purge ($urls, $all): a translation changed; purge these addresses (every language) from a page cache the plugin does not know, or the whole site when $all is true.

Test defined( 'LROB_AI_TRANSLATOR_VERSION' ) before using them.

Security

  • The API key is never shown, sent to the browser or logged; stored in the database, it is encrypted.
  • Every translation is checked against its source before it is kept: same tags, same links, same attributes, same shortcodes. A model, or a text written to mislead it, cannot add a script, a link or an attribute to a page.
  • The settings and the review are for administrators only. Every change of settings and every correction is logged with its author.
  • Nothing is sent to anyone but Anthropic, and only the content you translate.

Requirements

  • WordPress 6.7 or later, PHP 8.4 or later (8.5 recommended).
  • An Anthropic API key.
  • A permalink structure other than Plain.

About

LRob - AI Translator is a free plugin by LRob, WordPress host (en français).

License

GPL-2.0-or-later. © LRob — www.lrob.fr.