=== COCOS Translate ===
Contributors: mstron
Author: COCOS.
Author URI: https://cocos.codes/
Tags: translation, multilingual, localization, hreflang, seo
Requires at least: 5.6
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.5
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Translate your whole WordPress site from the front end — machine translation, SEO-friendly language URLs and a switcher.

== Description ==

COCOS Translate makes your site bilingual without touching your theme or your content structure: it translates your site from its default language into one translation language of your choice. You can change the translation language at any time.

Core features:

* **Whole-page translation.** The rendered HTML is buffered, parsed and every visible text node plus common attributes (alt, title, placeholder, aria-label, meta descriptions, Open Graph / Twitter tags) is replaced with its translation.
* **Live translation of JS-rendered content.** A client-side layer (MutationObserver) translates content injected after page load - WooCommerce Cart/Checkout blocks, Gutenberg-hydrated blocks, AJAX fragments - using the same dictionary, and reports unknown strings so they get translated on the next visit.
* **Visual front-end editor.** Open any page in edit mode, click a string, type the translation, save. Works for content, menus, widgets, theme strings.
* **`gettext` translation.** Theme and plugin strings that pass through `__()` / `_e()` are translatable too.
* **Machine translation.** Google Cloud Translation v2 with your own API key. Translate on demand from the editor, in bulk from the admin, or automatically in the background via WP-Cron. (Other engines are available in COCOS Translate PRO, a separate plugin.)
* **SEO-friendly URLs.** The translated pages live under their own path prefix (e.g. `/fr/`). `hreflang` alternate links, `x-default`, translated `<html lang>` / `dir` and localized permalinks are handled for you.
* **Language switcher.** Shortcode `[cc_transla_switcher]`, a widget, a `cc_transla_language_switcher()` template tag, an optional floating switcher and optional nav-menu injection.
* **Built-in page cache** for anonymous visitors so translated pages are served without re-parsing.

== Installation ==

1. Upload the `cocos-translate` folder to `/wp-content/plugins/`.
2. Activate the plugin.
3. Go to **Settings → COCOS Translate**, pick your default language and the language to translate your site into.
4. Visit the front end, open the admin-bar **Translate Page** menu and start translating, or configure a machine-translation engine and run **Auto-translate** from the admin.

== External services ==

This plugin can send text to an external machine-translation service. It does so only if you choose "Google Translate" as the machine-translation engine and enter your own API key under **Settings → COCOS Translate → Machine translation**. With the engine set to "None" (the default), the plugin makes no external requests.

**Google Cloud Translation API (v2)**

* What it is / what it is used for: Google's machine-translation service, used to translate the strings of your site (page text, menu items, widget text and similar) into your translation language.
* What data is sent and when: the text strings to be translated, the source and target language codes, and your Google API key. This happens when you click the machine-translate button in the visual editor, run a bulk "Auto-translate" from the admin, or when automatic background translation (WP-Cron) or translate-on-access is enabled. No visitor personal data is sent — only the site strings that are missing a translation.
* Service provider: Google LLC. [Terms of Service](https://cloud.google.com/terms) · [Privacy Policy](https://policies.google.com/privacy) · [Cloud Privacy Notice](https://cloud.google.com/terms/cloud-privacy-notice)

Links to translate.cocos.codes in this readme and in the plugin's admin screens are ordinary hyperlinks; the plugin does not contact that site in the background.

== Notes / limitations ==

* URL translation uses the sub-directory method (`example.com/fr/…`). Sub-domains and separate domains are not supported.
* On sites with a full-page caching layer in front of PHP, exclude the `?cc-transla-edit` requests from that cache.
* Very large string tables load into memory per request; let the built-in page cache do its job.

== Changelog ==

= 1.0.5 =
* The plugin now translates your site into one translation language of your choice (Settings → COCOS Translate → Languages), changeable at any time.

= 1.0.4 =
* Maintenance release.

= 1.0.3 =
* Fix: language-prefixed URLs (e.g. /it/, /de/) returning a 404 on sub-directory installs — the language segment is now stripped without WordPress losing the site's own sub-directory.
* Fix: cached translated pages could be answered with a 502 by some proxies/CDNs because of an invalid HTTP header name on cache hits.
* Fix: a stray XML declaration could appear in the served HTML of translated pages.

= 1.0.2 =
* Compliance: documented the Google Cloud Translation external service (data sent, Terms of Service and Privacy Policy links) in this readme.
* Fix: the live-translation collector now answers a failed nonce check with an error response instead of a success message.
* Security: the text sent to the machine-translation engine from the visual editor is now sanitised on the server.
* The platform moved to a new domain — plugin URI, update-check host, and every in-admin link (pricing, features, account, changelog) now point at translate.cocos.codes.

= 1.0.1 =
* Fix: WooCommerce Cart/Checkout AJAX requests breaking on non-default-language pages.
* Fix: a self-referential translation loop and corrupted HTML entities that could appear in some translated pages.
* Fix: the visual editor no longer hides text that was already translated via `gettext`.
* Fix: the WordPress core admin bar is no longer picked up as translatable content.
* Improvement: rows in the languages table can now be reordered by drag-and-drop (the order also sets the language-switcher order).
* Improvement: clearer, more visible outline around translatable text in the front-end editor.
* Various translation-harvesting fixes and WordPress.org plugin-check compliance fixes (escaping, sanitization).

= 1.0.0 =
* First public release of COCOS Translate.
* Whole-page translation of the rendered HTML - visible text plus alt / title / placeholder / aria-label and SEO meta (description, keywords, Open Graph, Twitter).
* Live translation of content injected after page load (WooCommerce Cart/Checkout blocks, Gutenberg-hydrated blocks, AJAX fragments) via a MutationObserver layer that also reports unknown strings.
* Visual front-end editor: hover translatable text, click the pencil, edit the translation, save.
* `gettext` translation for theme and plugin strings.
* Machine translation with Google Cloud Translation v2 (your own API key) - on demand from the editor, in bulk, or automatically via WP-Cron.
* SEO-friendly per-language URLs (`/fr/`, `/de/` ...), `hreflang` alternates, `x-default`, translated `<html lang>` / `dir` and localized permalinks.
* Language switcher: shortcode `[cc_transla_switcher]`, widget, template tag, an optional floating switcher and nav-menu injection - with bundled SVG country flags.
* Built-in page cache for anonymous visitors.
* Glossary with "keep as-is" terms; numbers handled as variables so "83 products" / "90 products" translate once.
* Advanced tab with a "Danger zone" (delete all translations / reset settings).

== COCOS Translate PRO ==

This plugin translates your site into one language, with Google Translate on your
own API key. **COCOS Translate PRO** (https://translate.cocos.codes) is a separate
paid plugin for sites in several languages. It offers:

* **Several translation languages per site.**
* **One-click AI translation** through the COCOS Translate proxy — Google, DeepL,
  OpenAI, Claude and Gemini with **no provider API keys** to manage.
* A monthly **AI phrase quota** with optional top-up packs.
* **Priority support** and automatic updates from translate.cocos.codes.

PRO is optional and is distributed from translate.cocos.codes, not from WordPress.org.
