=== AI Translate BYOK ===
Contributors: deusacc
Tags: translation, multilingual, ai, localization, content
Requires at least: 6.0
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.5.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Translate posts and pages into any language with an AI model — bring your own API key (BYOK), draft review before publishing, no plugin subscription.

== Description ==

Reaching readers and buyers in their own language is one of the highest-leverage things a site can do, but per-word translation agencies are slow and expensive, and most "AI translate" plugins lock the good part behind a monthly subscription. AI Translate BYOK adds one button to the post editor: pick a language, click Translate, and a full draft translation — title and content, HTML and shortcodes preserved — appears ready for a human to review and publish.

Features:

* One-click translation from the post/page editor sidebar, for any public post type.
* Human review by default: translations are created as drafts, never overwrite the original, and only go live when you (or an editor) publish them. An "auto-publish" mode is available for teams that trust the pipeline.
* Preserves HTML structure, shortcodes and Gutenberg block markup — only the human-readable text is translated.
* No cost for the plugin itself: you use your own API key and only pay (if at all) the provider you choose.
* Built-in shortlist of the languages with the highest demand (Arabic, Hindi, Chinese, Khmer, Swahili) plus the usual European/Asian languages — or type any language name.
* Know the cost before you click: the editor box estimates the tokens and the price of the translation with your model (list prices of common OpenAI, Anthropic, Gemini and DeepSeek models built in, or your own price per 1M tokens).
* A dedicated Posts > AI Translations page listing every translation created, its status and its source.
* Multilingual SEO without a multilingual plugin: published translations and their original are linked with `hreflang` alternate tags (the original is the `x-default`), so search engines serve each reader the right language instead of treating the copies as duplicates. If Polylang or WPML is active, they handle this and the plugin stays out of the way.
* A language switcher for readers: the `[aitr_languages]` shortcode or the "AI Translate: languages" block lists the other languages of the current post. No branding or credit links on your site.

BYOK (Bring Your Own Key): the plugin ships no API key of its own and does not act as a paid intermediary — a specific requirement of the WordPress.org policy on plugins that use external services, and at the same time the reason it costs less than subscription-based competitors.

= Free vs Full version =

This version is free with no limits: translate as many posts as you like, into any language. [The full version](https://shop.lumnika.com/ai-translate-byok.html) (one-time payment, no subscription) is for sites translating a whole catalogue: bulk translation of many posts at once from the Posts list, translation of Yoast SEO / Rank Math titles and meta descriptions and of categories and tags, automatic linking of translations in Polylang or WPML, WooCommerce products (variations, custom and global attributes such as Color or Size, prices, SKU and stock kept in sync across languages), translated navigation menus (classic and block themes), Elementor pages (headings, text, buttons and tabs translated, layout and styles kept), per-language URLs without Polylang or WPML (translations served at /de/your-post/ with a 301 from the old address, the right html lang and one sitemap per language), automatic translation on publish with a glossary of terms to keep, and outdated-translation tracking: when you edit an original, its translations are flagged as outdated and can be re-translated in place, one by one or in bulk. It replaces this plugin in place, same settings, no license key.

== External services ==

This plugin sends the title and content of the post you choose to translate to the AI endpoint that you configure yourself in the settings (API base URL, API key and model). No request is sent anywhere until you enter your own credentials, and no data passes through any server belonging to the plugin author. Which provider receives the data, and under which terms and privacy policy, is entirely your choice — by default the plugin points at the OpenAI chat completions API (https://openai.com/policies/terms-of-use, https://openai.com/policies/privacy-policy).

== Installation ==

1. Upload the `ai-translate-byok` folder to `/wp-content/plugins/`.
2. Activate the plugin from the WordPress Plugins menu.
3. Go to Settings > AI Translate BYOK and enter your API key (and, if you are not using OpenAI, your provider's URL and model name).
4. Open any post or page, pick a language in the "AI Translate BYOK" box in the sidebar, and click Translate.

== Frequently Asked Questions ==

= Do I need an OpenAI key specifically? =
No. Pick your provider in the "Provider" list of the settings (OpenAI, OpenRouter, Anthropic Claude, Google Gemini, DeepSeek, Groq, Mistral or a local Ollama) and the base URL and a recommended model are filled in for you; paste your key and save. Any other endpoint compatible with the OpenAI "chat completions" API works too: choose "Custom" and enter its URL and model.

= Is there a free provider? =
Yes. Google Gemini and Groq both offer a free tier with an API key and no credit card; a local Ollama costs nothing at all. Pick one in the "Provider" list.

= Does the translation overwrite my original post? =
No. It always creates a new, separate post in the target language, linked back to the original.

= Does it publish automatically? =
Not by default. New translations are created as drafts so a human can review them before they go live. You can switch to "publish immediately" in the settings if you prefer.

= Does the plugin send my content to a server of its own? =
No. Requests go directly from your site to the API provider you configured yourself.

= Is there a limit on translations? =
No. The only cost is what your AI provider charges for the requests you make with your own key.

== Screenshots ==

1. The AI Translate BYOK box in the post editor sidebar: pick a language, click Translate.
2. The translation is created as a separate draft, headings, links and block markup preserved, ready for a human to review and publish.
3. Posts > AI Translations lists every translation with its language, status and source post.
4. Settings: any OpenAI-compatible endpoint (here Groq, a free tier), your own API key and model, and the status of new translations.

== Changelog ==

= Unreleased =
* Full version: Elementor pages are translated too: widget texts (headings, text editor, buttons, tabs and other repeaters) in two requests, layout, ids and page template kept.

= 1.5.2 =
* Fix: the Google Gemini preset now uses `gemini-3.5-flash-lite` (Google no longer serves `gemini-2.5-flash-lite` to new API keys).
* Full version: automatic updates from Plugins > Updates, with the license key included in your download.

= 1.5.1 =
* Fix: the DeepSeek preset now uses `deepseek-flash` (DeepSeek retired `deepseek-chat`); the Google Gemini preset uses the stable `gemini-2.5-flash-lite`.
* The cost estimate knows gpt-5-mini, gpt-5-nano, gemini-2.5-flash-lite, deepseek-flash and deepseek-v4-pro (DeepSeek at peak-hour rates).

= 1.5.0 =
* New: "Provider" list in the settings with OpenAI, OpenRouter, Anthropic (Claude), Google Gemini, DeepSeek, Groq, Mistral and Ollama (local): picking one fills in the base URL and a recommended model, with a link to get the API key. "Custom" keeps any OpenAI-compatible endpoint.
* The cost estimate knows the default models of the new providers.
* Developers: new `aitr_provider_presets` filter to add or change providers.

= 1.4.0 =
* Full version: WooCommerce global attributes (Color, Size...) are translated too: each term is translated once and reused across products, and variations and default selections point to the translated terms, so filters and variation pickers show the translated language.
* Full version: navigation menus of block themes (Twenty Twenty-Four, Twenty Twenty-Five...) are translated, with links pointing to the translated pages.

= 1.3.0 =
* New: cost estimate in the editor box before translating (tokens and USD for the selected language), based on the list price of common models or on your own price per 1M tokens in the settings.
* Developers: new `aitr_model_prices` filter to add or update model prices.

= 1.2.0 =
* New: `hreflang` alternate links between an original and its published translations (x-default = original), when Polylang/WPML are not active.
* New: `[aitr_languages]` shortcode and "AI Translate: languages" block, a simple language switcher for readers.
* Developers: new `aitr_lang_code` filter to map a custom language name to its hreflang code.
* Full version: outdated-translation tracking and "Re-translate with AI" (single, bulk, or all outdated at once).

= 1.1.1 =
* Translations created in the background (WP-Cron) keep the author of the original post.

= 1.1.0 =
* No monthly limit any more: the free version translates without quotas.
* Developers: new `aitr_translation_created` action after each translation.

= 1.0.1 =
* Fix: translations of Gutenberg posts could lose the block markup (`<!-- wp:... -->` comments), because the sanitization step treated them as unrecognized HTML comments and stripped them. Block structure is now preserved.

= 1.0.0 =
* First release: BYOK translation from the post editor, draft-by-default workflow, translations list page, free/full-version tier.
