=== SaintLang ===
Contributors: sainthossam
Tags: translation, multilingual, localization, hreflang, seo
Requires at least: 6.5
Tested up to: 7.1
Stable tag: 1.0.0
Requires PHP: 8.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Editor-first multilingual content, same-ID translations, language URLs, string translation, SEO, glossary and optional AI providers.

== Description ==

SaintLang is a multilingual translation plugin for WordPress focused on a fast editor workflow.

Each language stays attached to the same native WordPress post, page, product, or custom post ID. SaintLang stores translated fields by language instead of creating a second WordPress post for every translation.

Key features:

* One language bar in Gutenberg and the Classic Editor: pick a language and the native editor opens in it, with WordPress' own Update button saving that language.
* Translates titles, content, excerpts and Advanced Custom Fields (all field types, including repeaters and flexible content).
* Posts and Pages list language tabs without full-page reloads.
* Same WordPress content ID across all configured languages.
* Original-content fallback until a missing translation is saved.
* Explicit language catalog: only languages selected by an administrator are configured.
* Language URL modes: language directories such as /en/ (recommended), subdomains such as en.example.com, or a ?lang= parameter.
* hreflang and x-default output.
* String Translation for WordPress Gettext strings on the public site.
* Translation Memory and terminology glossary.
* Optional AI translation through the WordPress AI Client (WordPress 7.0+), DeepL or Google Cloud Translation.
* WooCommerce, ACF, Yoast SEO, Rank Math, Elementor and Bricks compatibility helpers.
* Header language switcher and [saintlang_switcher] shortcode.
* English and Arabic SaintLang dashboard UI with RTL support.
* REST API and WP-CLI commands.

== Installation ==

1. Install SaintLang from Plugins > Add New, or upload the SaintLang ZIP from Plugins > Add New > Upload Plugin.
2. Activate SaintLang.
3. Open SaintLang from the WordPress admin menu.
4. Add only the languages you want to use.
5. Choose the primary language and URL structure.
6. Open a post, page or product to use the SaintLang editor language tabs.
7. Add AI provider credentials only if you want to use optional AI translation.

== Frequently Asked Questions ==

= Does SaintLang create a separate WordPress post for every language? =

No. SaintLang keeps translated fields attached to the same native WordPress content ID.

= What happens when a translation is missing? =

SaintLang shows the source-language content as a fallback until that language is actually translated and saved.

= Which URL structure is recommended? =

Language directories are recommended for multilingual SEO, for example /en/sample-page/. Language directories need pretty permalinks; on sites that use plain permalinks SaintLang automatically uses the ?lang= parameter instead.

= Can each language use its own subdomain? =

Yes. Choose "Languages in subdomains" in SaintLang > Settings to serve each language from a subdomain such as en.example.com, while the primary language stays on the main domain. First point every language subdomain to your WordPress site in your DNS and hosting control panel, with an SSL certificate that covers it.

= Does SaintLang translate Advanced Custom Fields? =

Yes. Open a post in a language from the SaintLang language bar and edit its ACF fields as usual; saving stores them for that language only. On the site, get_field() and the_field() return the value for the visitor's language, falling back to the original when a field has not been translated. AI translation also translates ACF text, textarea and WYSIWYG fields.

= Does SaintLang require an AI service? =

No. AI translation is optional. Manual translation, language management, editor tabs, URL handling, SEO, glossary and string translation work without an AI account.

= What happens to my translations if I delete the plugin? =

Translations are kept by default so that deleting the plugin never destroys translated content. Stored AI provider keys are always removed. To remove every SaintLang table, option, role and post meta, add `define( 'SAINTLANG_REMOVE_ALL_DATA', true );` to wp-config.php before deleting the plugin.

== Shortcode ==

Use:

`[saintlang_switcher]`

Optional attributes:

`[saintlang_switcher flags="1" names="1" hide_current="0" style="dropdown"]`

`style` accepts `dropdown`, `pills` or `minimal`.

== External Services ==

SaintLang connects to third-party services only for the optional AI translation features described below. No request is sent unless the provider has been configured and an authorized user explicitly runs an AI translation action or job.

= WordPress AI Client (WordPress 7.0+) =

When the "WordPress AI" provider is selected and an authorized user runs an AI translation, SaintLang sends the text to translate and translation instructions to the WordPress AI Client. WordPress then sends it to the AI provider the site owner connected in Settings → Connectors. SaintLang does not store AI provider credentials or contact AI providers directly; the connected provider's own terms and privacy policy apply.

= DeepL =

Used to translate text with DeepL. When requested, SaintLang sends the text to translate and the source/target language codes to api.deepl.com or api-free.deepl.com.

DeepL Terms: https://www.deepl.com/pro-license
DeepL Privacy Policy: https://www.deepl.com/privacy

= Google Cloud Translation =

Used to translate text with Google Cloud Translation. When requested, SaintLang sends the text to translate and the source/target language codes to translation.googleapis.com.

Google Cloud Terms: https://cloud.google.com/terms/
Google Privacy Policy: https://policies.google.com/privacy

== Privacy ==

SaintLang does not include telemetry, advertising, or hidden tracking.

When a visitor chooses a language, SaintLang stores a `saintlang_lang` cookie so background requests (for example AJAX cart updates) use the same language. Page URLs always decide which language a page is shown in. SaintLang stores the SaintLang dashboard-language preference in WordPress user meta for logged-in users.

Content is sent to an external AI/translation provider only when an authorized user has configured that provider and explicitly runs an AI translation action or job.

== WP-CLI ==

`wp saintlang languages`
`wp saintlang scan-strings`
`wp saintlang translate 123 --to=ar`
`wp saintlang seo-audit`

== Developer Notes ==

Post types can be excluded from translation (no language bar, no translation storage) with the `saintlang_translatable_post_type` filter: `add_filter( 'saintlang_translatable_post_type', fn( $on, $type ) => 'my_form_entry' === $type ? false : $on, 10, 2 );`

SaintLang uses WordPress capabilities, permission callbacks on REST routes, native enqueue functions, the Options API, user meta, WP-Cron / Action Scheduler integration when available, and WordPress database APIs.

No third-party JavaScript UI framework or CDN asset is used. The admin interface font (Cairo), icons and country flags are bundled with the plugin, so SaintLang never loads images or fonts from external servers.

== Source Code ==

SaintLang has no build step. The JavaScript files in assets/js/ (admin.js, editor.js, classic-editor.js, content-list.js, language-switch.js, frontend.js) and the stylesheets in assets/css/ are the original, human-readable source files. They are written by hand in plain JavaScript and CSS, with no bundler, transpiler or minifier, and are shipped exactly as written. No npm, webpack or other build tooling is needed to read, modify or rebuild them.

The inline SVG icons in the JavaScript files are copied unchanged from Lucide (https://github.com/lucide-icons/lucide, ISC License).

== WordPress Admin Isolation ==

SaintLang does not reposition, restyle, translate, or change the direction of the native WordPress admin menu or toolbar.
Dashboard Arabic/English direction changes are scoped only to the SaintLang application area.

== Credits ==

* Cairo font by The Cairo Project Authors, licensed under the SIL Open Font License 1.1 (assets/fonts/OFL.txt).
* Interface icons from Lucide (https://lucide.dev), licensed under the ISC License.
* Country flags from flag-icons by Panayiotis Lipiridis (https://github.com/lipis/flag-icons), licensed under the MIT License (assets/flags/LICENSE.txt).

== Changelog ==

= 1.0.0 =
* Initial release.
* Same-ID translations for posts, pages, products and custom post types.
* One language bar for Gutenberg and the Classic Editor; the native editor opens in the chosen language.
* Posts and Pages list language tabs.
* Language directories (/fr/), subdomains (fr.example.com) and query parameter URL modes, with hreflang, x-default and canonical support.
* Header language switcher and [saintlang_switcher] shortcode.
* String Translation for Gettext strings on the public site.
* Translation Memory and terminology glossary.
* Advanced Custom Fields translation (all field types) from the same language bar.
* Optional AI translation through the WordPress AI Client, DeepL or Google Cloud Translation.
* WPML import.
* English and Arabic dashboard with full RTL support.
* REST API and WP-CLI commands.
* Built for large sites: object-cache aware lookups, compact rewrite rules and automatic log cleanup.

== Upgrade Notice ==

= 1.0.0 =
Initial release.
