=== Translera – Automatic Google Translate for Multilingual Websites ===
Contributors: ilmosys
Tags: translation, multilingual, google translate, language switcher, automatic translate
Requires at least: 6.0
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.0.4
License: GPLv3 or later
License URI: https://www.gnu.org/licenses/gpl-3.0.html

Add multilingual WordPress translation with Google Translate, SEO hreflang URLs, Elementor, Gutenberg, and a language switcher.

== Description ==

Translera is a lightweight automatic WordPress translation plugin for creating multilingual websites with clean language URLs, Google Translate support, and flexible language switchers.

Use Translera to add a multilingual experience to blogs, business websites, landing pages, WooCommerce-style storefronts, documentation sites, and Elementor pages. The plugin supports language prefixes such as `/es/`, `/fr/`, and `/ar/`, query parameter language URLs, automatic hreflang tags, RTL language handling, and more than 30 languages.

= Key Features =

* **Google Translate integration** - translate content with Google Translate using the free endpoint or your own Google API key.
* **SEO-friendly language URLs** - use clean subdirectory URLs like `example.com/es/page/` or query URLs like `example.com/page/?lang=es`.
* **Automatic hreflang tags** - help search engines understand alternate language versions of each page.
* **Language switcher shortcode** - add `[translera_switcher]` to pages, posts, widgets, or templates.
* **Gutenberg block** - insert a language switcher directly in the WordPress block editor.
* **Elementor widget** - add a native Translera Language Switcher widget to Elementor layouts.
* **Integration controls** - Elementor widget and Gutenberg block integrations are enabled by default and can be managed from Translera settings.
* **Multiple switcher styles** - choose dropdown, flags-only, or list layouts.
* **30+ supported languages** - including English, Spanish, French, German, Arabic, Chinese, Japanese, Portuguese, Hindi, Hebrew, Persian, Urdu, and more.
* **RTL support** - automatically handles right-to-left languages such as Arabic, Hebrew, Persian, and Urdu.
* **Browser language detection** - optionally detect the visitor's preferred language.
* **Translation caching support** - reduce repeated translation requests with transient and browser-side caching.
* **Lightweight frontend assets** - designed to add multilingual tools without heavy page-builder dependencies.

= Why Use Translera? =

Translera helps make your WordPress site easier to read for international visitors while keeping your URLs structured for multilingual SEO. It is built around standard WordPress APIs, so it works with most themes and can be used through shortcode, block editor, Elementor, or PHP template code.

== Installation ==

1. Upload the `translera` folder to the `/wp-content/plugins/` directory.
2. Activate the plugin from the WordPress Plugins screen.
3. Go to **Translera > Settings** in the WordPress dashboard.
4. Choose your default language, enabled languages, and URL structure.
5. Add the language switcher using a shortcode, Gutenberg block, or Elementor widget.
6. If you use subdirectory URLs, save your WordPress permalinks once after activation if language URLs do not load immediately.

== Configuration ==

= General Settings =

* Choose the default site language.
* Enable the languages you want to show in the switcher.
* Select Google Translate as the translation method.
* Choose subdirectory URLs or query parameter URLs.
* Enable or disable browser language detection.
* Enable or disable the Elementor widget and Gutenberg block integrations. Both are enabled by default.

= URL Structures =

Translera supports two multilingual URL formats:

* **Subdirectory URLs:** `example.com/es/privacy-policy/`
* **Query parameter URLs:** `example.com/privacy-policy/?lang=es`

Subdirectory URLs are recommended for clean, SEO-friendly multilingual site structure.

= Google Translate =

Translera can translate using Google Translate. You can leave the Google API key field empty to use the free translation endpoint, or add your own API key for Google Cloud Translation API requests.

= Language Switcher =

The language switcher can show flags, native language names, translated language names, or a compact flags-only layout. Available styles include:

* Dropdown
* Flags only
* List

== Usage ==

= Shortcode =

Add the language switcher anywhere shortcodes are supported:

`
[translera_switcher]
`

Use shortcode options to customize the output:

`
[translera_switcher style="flags" show_flags="true" show_names="false"]
`

= Gutenberg Block =

The Gutenberg block integration is enabled by default from **Translera > Settings > General > Integrations**.

1. Edit a page or post with the block editor.
2. Search for **Translera Language Switcher**.
3. Insert the block.
4. Choose the switcher style and display options in the block sidebar.

= Elementor Widget =

The Elementor widget integration is enabled by default from **Translera > Settings > General > Integrations**.

1. Edit a page with Elementor.
2. Search for **Translera Language Switcher**.
3. Drag the widget into your layout.
4. Configure style, flags, native names, and alignment.

= PHP Template Usage =

Theme developers can render the switcher in template files:

`
<?php
echo wp_kses_post(
    Translera_Language_Switcher::render_block(
        array(
            'style'       => 'dropdown',
            'show_flags'  => true,
            'show_native' => true,
            'show_names'  => true,
        )
    )
);
?>
`

== Supported Languages ==

Translera includes support for English, Spanish, French, German, Arabic, Chinese, Japanese, Portuguese, Russian, Italian, Korean, Dutch, Polish, Turkish, Vietnamese, Thai, Indonesian, Hindi, Swedish, Danish, Finnish, Norwegian, Greek, Hebrew, Ukrainian, Czech, Romanian, Hungarian, Bengali, Malay, Persian, Urdu, and more.

== SEO Features ==

Translera is built for multilingual SEO workflows:

* Clean language-specific URLs.
* Automatic `hreflang` alternate links.
* `x-default` hreflang output.
* Language-aware page, post, home, and term links.
* RTL-aware HTML attributes for supported languages.

== FAQ ==

= Is Translera free? =

Yes. Translera is free to install and use. Google Translate API usage may require your own Google account and may be subject to Google's pricing and limits.

= Do I need a Google Translate API key? =

No. You can leave the API key field empty to use the free Google Translate endpoint. If you prefer the official Google Cloud Translation API, add your own API key in the settings.

= Does Translera work with Elementor? =

Yes. Translera includes a dedicated Elementor Language Switcher widget.

= Does Translera work with Gutenberg? =

Yes. Translera includes a WordPress block for adding a language switcher in the block editor.

= Can I use a shortcode? =

Yes. Use `[translera_switcher]` anywhere WordPress shortcodes are supported.

= Does Translera add hreflang tags? =

Yes. Translera outputs alternate hreflang links for enabled languages and an `x-default` link.

= Which URL structure is best for SEO? =

Subdirectory URLs such as `example.com/es/page/` are usually preferred for multilingual SEO because each language version has a clean, crawlable URL.

= Does Translera support RTL languages? =

Yes. Translera supports RTL handling for Arabic, Hebrew, Persian, and Urdu.

= Will it work with my theme? =

Translera uses standard WordPress hooks and should work with most modern WordPress themes.

== External services ==

This plugin uses Google translation services to translate page content and language-switcher labels. It may also connect to Freemius for optional usage tracking after an admin opts in. Translation requests are sent only when a visitor views a non-default language version of your site (or when an administrator runs a translation test from the settings screen).

= Freemius (optional usage tracking) =

Translera includes the Freemius SDK for optional usage analytics and insights. No tracking data is sent until a site administrator opts in from the Freemius connect screen (you can skip). If you opt in, Freemius may receive diagnostic information such as the site URL, plugin version, SDK version, WordPress/PHP versions, and the admin name/email used for the opt-in. You can opt out later from the Plugins screen.

**Service provider:** Freemius, Inc. — [Terms of Service](https://freemius.com/terms/), [Privacy Policy](https://freemius.com/privacy/).

= Google Cloud Translation API =

When you enter a Google Cloud API key in **Translera > Settings**, the plugin sends translation requests to the official Google Cloud Translation API (`https://translation.googleapis.com/language/translate/v2`).

**What is sent:** The text to translate, source language code, target language code, and your API key.

**When it is sent:** During server-side translation (when enabled via the `translera_auto_translate` filter), REST API translation tests from the admin, and any server-side caching of translations.

**Service provider:** Google LLC — [Terms of Service](https://cloud.google.com/terms/service-terms), [Privacy Policy](https://policies.google.com/privacy).

= Google Translate (free endpoint) =

When no API key is configured, the plugin may use Google's public translate endpoint (`https://translate.googleapis.com/translate_a/single`) for server-side and browser-side translation.

**What is sent:** The text to translate, source language code, target language code, and a client identifier (`gtx`). No API key is sent.

**When it is sent:** When a visitor loads a page in a non-default language (browser-side translation in `frontend.js`), during server-side translation when enabled, and during admin translation tests.

**Service provider:** Google LLC — [Google Terms of Service](https://policies.google.com/terms), [Privacy Policy](https://policies.google.com/privacy).

**Note:** The free endpoint is not part of the official Google Cloud Translation API and may be subject to usage limits or changes by Google. For production sites, Google recommends using the Cloud Translation API with your own API key.

== Screenshots ==

1. Translera settings dashboard.
2. Language switcher dropdown.
3. Flags-only language switcher.
4. Elementor language switcher widget.
5. Gutenberg language switcher block.

== Changelog ==
= 1.0.4 - 12/07/2026 =
* Fixed: Elementor widget loading, and integration setting.
* Fixed: Auto-detect redirects once to the language URL; safer URL filters and hreflang.
* Improved: Translation cache, queued client-side translate, shortcode booleans, and frontend assets.
* Improved: Switcher accessibility, block.json registration, and uninstall cleanup.

= 1.0.3 - 07/06/2026 =
* Fixed: Custom post type URLs with language prefixes resolve correctly instead of showing the home page or a 404.
* Fixed: Language-prefixed CPT permalinks now include the correct `post_type` and `name` query mapping after URL parsing.
* Added: `post_type_link` filter support so custom post type permalinks keep the active language prefix.

= 1.0.2 - 21/05/2026 =
* Updated: Tested up to WordPress 7.0

= 1.0.1 - 20/05/2026 =
* Document Google translation external services in readme (terms and privacy links).
* Remove inline admin CSS; use enqueued stylesheets.
* Escape filter and shortcode output per WordPress security standards.

= 1.0.0 - 20/05/2026 =
* Initial release.

== Upgrade Notice ==
