=== LolaCore for Polylang ===
Contributors: vanguardhive
Tags: polylang, multilingual, translation, ai assistant, lola
Requires at least: 7.0
Tested up to: 7.0
Requires PHP: 8.1
Stable tag: 1.0.5
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Translate a full Polylang page without rebuilding it. Talk to Lola in wp-admin, she keeps the layout and saves a linked draft.

== Description ==

Polylang already gives your site multiple languages, linked posts, and clean URLs. The pages are where the hours go. Hero copy, feature lists, CTAs, and FAQs sit inside dozens of Gutenberg blocks or Elementor widgets, far below the page title. Copy-pasting between tabs breaks block markup. Translating categories on their own leaves the site half done.

You ask Lola to translate a page and she does the whole thing, segment by segment, into a linked Polylang draft. Gutenberg block structure and Elementor layout stay intact on the server; only the text changes. Ask for a Portuguese version of a landing page, or a linked Spanish category when the taxonomy still needs work. She reads Polylang's translation groups, shows a sample in the approval card, and holds it as a draft until you publish.

Same Polylang. Same structure. You stopped tab-hopping and started asking.

This is an addon. It needs [LolaCore](https://wordpress.org/plugins/lolacore) and [Polylang](https://wordpress.org/plugins/polylang/) active on the same site. Polylang Pro works too; the addon uses the same `pll_*` APIs on both editions.

For walkthroughs and example conversations, see [lolacore.com/lolacore-for-polylang](https://lolacore.com/lolacore-for-polylang).

= One addon, two surfaces: wp-admin and MCP =

Every ability is available in the Lola chat inside WordPress admin and through LolaCore's MCP server. Same 17 tools, same guardrails, same confirmation before writes. Use whichever surface fits your workflow; you do not learn two different products.

= Example: coverage and a page translation =

The exchange below is the same whether you type in wp-admin or call the abilities from Cursor or Claude Code. Names instead of database IDs keep it readable for everyone on the team.

**In wp-admin (Lola chat):**

> **You:** How much of the site is still missing in Spanish?
>
> **Lola:** Spanish coverage: about two thirds of pages, no posts yet, most categories done, one tag still open. The page *Nos sacs à dos* already has a Spanish draft (*Nuestras mochilas*). Portuguese is still missing for that page.
>
> **You:** Translate *Nos sacs à dos* into Portuguese. Keep the layout, draft only.
>
> **Lola:** I will create a linked Portuguese draft from the French original: the full page, with title, headings, body copy, and buttons (8 text segments). Gutenberg block layout preserved. Here is a short preview of the translation. Approve to save as draft?

**From an MCP client (same site, same abilities):**

> **You:** Run translation coverage for Portuguese, then translate the page *Nos sacs à dos*.
>
> **Lola:** Coverage first: 0% of pages in Portuguese. *Nos sacs à dos* has no Portuguese slot yet; the French page has 8 segments across headings, paragraphs, and buttons. I prepared the full-page Portuguese draft with the same structure. Confirm execution?

She checks the translation slot before creating duplicates and preserves layout server-side, with the same rules on both surfaces.

= Full pages: Gutenberg blocks and Elementor =

This addon is built for full-page translation. Lola walks the page tree, extracts every translatable text segment in order, translates them, and writes them into a linked Polylang draft. You review the whole page in the block editor or Elementor before publishing.

**Gutenberg:** Headings, paragraphs, buttons, lists, columns, cover blocks, and nested block content. Block JSON, attributes, and structure are preserved; Lola replaces copy inside the layout, not the layout itself.

**Elementor:** When [Elementor](https://wordpress.org/plugins/elementor/) is active, the same flow reads the Elementor widget tree and clones the page structure server-side. Text inside headings, text editors, buttons, and other widgets is translated segment by segment while the layout stays intact.

Categories and tags are supported too, useful for navigation and archives. The core value is translating complete pages without rebuilding them by hand.

= What Lola does with Polylang: 17 abilities =

Ask her for any of these in chat or over MCP.

**Languages and settings (8 abilities)**

* Lists your languages with their locales, the default flag, and optional post counts.
* Adds, updates, or removes a language. Sets the default one.
* Reads your Polylang settings: URL mode, hide default, sync fields, translated post types and taxonomies.
* Updates those settings and configures which custom post types and taxonomies are translatable.

**Posts and pages (4 abilities): full-page translation**

* Reads a post's translation group, its missing languages, the ordered `source_segments` (every text block on the page), and whether the page is built with Gutenberg or Elementor.
* Creates a linked translation draft with the translated title and all page segments, Gutenberg blocks or Elementor widget text preserved and layout unchanged.
* Assigns a language to a post, or links existing posts into one translation group when languages are already assigned.

**Terms (4 abilities)**

* Reads category or tag translation groups, and looks them up by name in the default language.
* Assigns a language to a term, or creates a linked translation.
* Links existing terms across languages.

**Coverage (1 ability)**

* Audits translation coverage per language: posts and pages by type, plus categories and tags, so you know which full pages to translate next.

= Built-in domain knowledge =

The addon ships a playbook and a skill Lola loads when working in this domain: how Polylang models languages and sync fields, and the canonical workflow (coverage first, check the slot, draft-first, parents before child terms). You do not configure them; they register when the addon is active.

= You approve before anything publishes =

Every write runs through LolaCore's confirmation flow. Lola shows target language, title, and a short preview of the translation sample. You approve or cancel. New translations save as drafts unless you explicitly ask to publish. An existing translation slot is protected; a write against one stops with a clear error.

= Third-party addon, not affiliated with Polylang =

Polylang is a registered trademark of WP SYNTEX. LolaCore for Polylang is an independent addon built by LolaCore. It is not affiliated with, endorsed by, or sponsored by WP SYNTEX or the Polylang team. You install Polylang separately from WordPress.org.

= What you need =

* WordPress 7.0+
* PHP 8.1+
* [LolaCore](https://wordpress.org/plugins/lolacore), active
* [Polylang](https://wordpress.org/plugins/polylang/) (Free or Pro), active
* [Elementor](https://wordpress.org/plugins/elementor/) (optional) — required to translate Elementor-built pages

== Installation ==

1. Install and activate [LolaCore](https://wordpress.org/plugins/lolacore) and Polylang. Configure your languages in Languages → Languages.
2. Upload the `lolacore-for-polylang` folder to `wp-content/plugins/`, or install the ZIP from Plugins → Add New → Upload Plugin.
3. Activate LolaCore for Polylang from the Plugins screen.
4. Open the Lola chat in wp-admin. The Polylang domain appears in the panel, ready to use.

For MCP, connect your site through LolaCore's bundled MCP server (same abilities as the chat). No extra API keys for this addon beyond the AI provider you already configured in WordPress (Settings → Connectors).

== Frequently Asked Questions ==

= Do I need LolaCore to use this? =

Yes. This addon adds the Polylang domain to LolaCore. It does not run on its own. Install and activate LolaCore first.

= Do I need Polylang? =

Yes. Polylang provides the multilingual structure. This addon lets Lola read and update translations through Polylang's APIs. Install Polylang separately.

= Does this work with Polylang Pro? =

Yes. The addon uses the same Polylang APIs on Free and Pro. Features that are Pro-only inside Polylang itself (such as certain URL options) stay configured in Polylang; Lola does not replicate Pro-only routing.

= Does this work with Gutenberg and Elementor? =

Yes. Full-page translation is the main use case. Gutenberg pages are handled natively: Lola extracts text from each block and writes translations back without breaking block markup. Elementor pages use the same `translatePost` ability when Elementor is active: Lola reads the widget tree on the server and clones the layout, translating text segment by segment.

= What does Polylang keep handling after I install this? =

Polylang keeps managing languages, URLs, switchers, and translation groups. This addon lets Lola operate on top of that structure from conversation or MCP.

= How do I stay in control of what Lola saves? =

Lola generates translations through the AI provider you configured, and every write shows a preview and waits for your approval before it saves. New post translations default to draft so you review in WordPress or Elementor before publishing. You stay the quality gate.

= Can I use this from Cursor, Claude Code, or another MCP client? =

Yes. All 17 abilities are exposed through LolaCore's MCP server with the same schemas and guardrails as the wp-admin chat. Discover abilities, read schemas, and execute with your client; slot checks and draft defaults apply the same way.

= What happens if I deactivate Polylang? =

The addon shows an admin notice and stops registering its abilities until Polylang is active again. No fatal errors.

= Where does my content go when Lola translates? =

Polylang data is read and written on your server through Polylang's PHP APIs. When Lola translates, post and term text is sent to the AI provider you configured in WordPress (Settings → Connectors) so the model can produce the target language. This addon does not route data through LolaCore servers. See External Services below.

== External Services ==

= AI Providers (translation and chat) =

When you ask Lola to translate content or chat about your site, text is sent to whichever AI provider you configured in WordPress's built-in AI settings (Settings → Connectors). LolaCore does not operate its own translation servers.

**Data sent to your provider when translating:**

* Source post or term text (titles, ordered text segments, excerpts when provided)
* Your chat messages and tool parameters
* Relevant memory facts if Lola needs site context

**Data this addon keeps on your server:**

* WordPress passwords, database credentials, and wp-config secrets
* Unrelated post content beyond what you asked to translate

**When this happens:** Only when you send a chat message or execute a translation ability (chat or MCP). No background translation jobs.

**Supported providers:** Same list as [LolaCore](https://wordpress.org/plugins/lolacore/) (OpenAI, Anthropic, and others you enable in Connectors). Use each provider's terms and privacy policy.

== Changelog ==

= 1.0.5 =
* Elementor HTML widgets: preserve whitespace between inline styled text runs when merging translated segments (fixes glued words like "Pidesen" after bold-to-normal transitions).

= 1.0.4 =
* Elementor page translation uses Elementor directly — no separate LolaCore addon required for builder pages.
* Self-contained Elementor read/write helpers bundled for translation pipeline compliance.

= 1.0.3 =
* Category affinity: co-include `content` and `system` with `polylang` so chat can resolve pages (getContent, getSiteSettings/page_on_front) before translating.
* Skill: homepage → getSiteSettings reading group; page search → getContent with post_type page.

= 1.0.2 =
* Knowledge pack: playbook is domain reference only; skill is translation craft (not a parallel system prompt).
* SOP: resolve page identity with core getContent before segment reads; coverage only for site-wide audits.
* Playbook: documents Polylang admin language filter; removes ability-only silo wording.

= 1.0.1 =
* Elementor HTML widgets: extract and translate visible text inside custom markup while preserving layout and attributes.
* Chat/MCP: accept title_translation as an alias for translated_title; clearer validation hints when Elementor segments are missing.

= 1.0.0 =
* Initial public release.
* 17 Polylang abilities: languages, settings, post/page translation (Gutenberg and Elementor), terms, and coverage audits.
* Playbook `multilingual-sites` and skill `site-translation` bundled for domain-aware assistance.
* Draft-first translations with confirmation previews; guards that protect existing translation slots.
* Full MCP parity with wp-admin chat for all 17 abilities.

== Upgrade Notice ==

= 1.0.5 =
Fixes missing spaces in Elementor HTML translations when inline formatting changes mid-sentence.

= 1.0.4 =
Elementor pages translate when Elementor is active — no extra LolaCore addon needed for builder translation.

= 1.0.3 =
Polylang routes now include content and system tools — Lola can resolve the homepage and page titles before translating.

= 1.0.2 =
Sharper knowledge pack: Lola resolves pages with core tools before translating; no forced coverage on single-page requests.

= 1.0.1 =
Elementor HTML widget translation and improved translatePost parameter handling for chat workflows.

= 1.0.0 =
First release. Requires LolaCore and Polylang.
