=== AI Translate For Polylang ===
Contributors: jamesdlow
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=K6VKWB3HZB2T2&item_name=Donation&currency_code=USD&bn=PP%2dDonationsBF
Tags: language, translate, multilingual, translation, polylang
Requires at least: 3.0
Tested up to: 7.1.0
Stable tag: trunk
License: MIT
License URI: https://opensource.org/licenses/MIT

Add auto AI translation caperbility to Polylang using OpenAI/ChatGPT, Anthropic/Claude, Google/Gemini or OpenRouter.

== Description ==
Add auto AI translation caperbility to Polylang using OpenAI/ChatGPT, Anthropic/Claude, Google/Gemini or OpenRouter.

This plugin connects to OpenAI/ChatGPT (api.openai.com), Anthropic/Claude (api.anthropic.com), Google/Gemini (generativelanguage.googleapis.com) or OpenRouter (openrouter.ai) in PHP from the Wordpress admin in order to faciliate the translations. When a Wordpress author has the plugin activated, has entered their OpenAI API key in the settings, and clicks new translation from Polylang, the plugin will send the post title and post content to the selected service for tranlsation.

== Installation ==

This section describes how to install the plugin and get it working.

1. If not already installed, install and activate the Polylang plugin https://www.wordpress.org/plugins/polylang/
2. Upload entire `ai-translate-polylang` folder to the `/wp-content/plugins/` directory
3. Activate the plugin through the 'Plugins' menu in WordPress
4. Edit AI Translate settings at Languages -> AI Translate
5. Click the translate button on a post or page

== Frequently Asked Questions ==


== Screenshots ==


== Changelog ==

= 1.1.9 =
* Translate titles with their own prompt. A body prompt makes models expand a bare headline into a whole article, which then got saved as the post title
* Validate every translation before saving it: reject html or multi-line output in a title, reasoning the model leaked instead of an answer, and content far shorter than its source
* Never save a failed translation. translate_post() now keeps the source text and holds the post as a draft instead of publishing the API error message
* Handle WP_Error responses, error envelopes returned with HTTP 200, truncated responses, and providers that return content in parts
* Skip thinking blocks in Claude and Gemini responses, and ask OpenRouter to exclude reasoning
* Size max_tokens to the input instead of a fixed 5000, so long posts stop being truncated
* Retry once before giving up

= 1.1.8 =
* Add OpenRouter support

= 1.1.7 =
Rename Setting

= 1.1.6 =
* Remove dependency on openai library, and use custom implementation

= 1.1.5 =
* Fixes for PHP 8 warnings
* Hook for excerpt translation
* Change prompt to text box

= 1.1.4 =
* Bugfix when retrieving Gemini key

= 1.1.3 =
* Make default Gemini model gemini-2.5-flash

= 1.1.2 =
* Change AI model to text string, so you can choose your own model
* Fix internal translate function for scripting
* Add option to overwrite on internal translate function

= 1.1.1 =
* Add Google Gemini support

= 1.1.0 =
* Set post language on new post before trying to translate

= 1.0.9 =
* Fix PHP 8.X warning

= 1.0.8 =
* Correctly set author in translated post

= 1.0.7 =
* Copy author and dates when translating post

= 1.0.6 =
* Add helper function for programmatic translation in PHP

= 1.0.5 =
* Edit prompt to make sure only the new content is returned

= 1.0.4 =
* Use PageApp for SettingsLib if avaliable

= 1.0.3 =
* Add Claude API
* Add options to translate or clear out prior meta

= 1.0.2 =
* Futher updates for Wordpress plugin standards

= 1.0.1 =
* Updates for Wordpress plugin standards

= 1.0.0 =
* Initital version