=== LiveLang – Smart Multilingual Visual Translator ===
Contributors: papanbiswasbd, arsyntax
Tags: translator, visual translator, translation, multilanguage, visual editor
Requires at least: 5.0
Requires PHP: 7.4
Tested up to: 7.0
Stable tag: 2.1.5
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Inline visual translator for WordPress with multi-language support, media translation, SEO-friendly URLs, and high-performance JSON caching.

== Description ==

LiveLang is a powerful visual translation plugin for WordPress that lets you translate or modify any text directly from the frontend — instantly.

Enable Translate Mode → click any text → edit → save.

No file editing. No searching for strings. No .po/.mo files. No duplicate pages.

[youtube https://www.youtube.com/watch?v=x_pem4ZeGWw]

🚀 Multi-Language System (SEO Optimized)

LiveLang provides a structured multi-language system with SEO-friendly URLs and built-in language switching.

You can manage multiple languages within a single page — no need to create duplicate pages or manage complex translation files.

Example URL structure:
domain.com/en/page
domain.com/bn/page

Clean, scalable, and SEO-friendly.

🚀 Media Translator

LiveLang includes a built-in Media Translator that allows you to display different images for different languages.

Assign language-specific images and create a fully localized experience beyond text translation.

🚀 High-Performance JSON Cache System

LiveLang uses a smart JSON-based caching system to deliver fast performance.

Translations are cached after the first load, significantly reducing database queries and improving page speed.

Benefits:

* Faster page loading
* Reduced database queries
* Smooth multilingual experience
* Scalable performance for large websites

== Key Features ==

* Visual inline text editing (frontend)
* Full multi-language support
* Translate multiple languages within the same page
* Media Translator for language-based images
* Page-based & global translation modes
* SEO-friendly language URL structure
* Built-in language switcher
* Language switcher shortcode: [livelang_language_switcher]
* Shortcode support for posts, pages, menus, and PHP (do_shortcode)
* Country flags for each language
* Automatic lang attribute support (SEO & accessibility)
* JSON-based translation caching system
* Elementor editor compatibility
* Works with any theme, builder, or plugin
* WooCommerce compatible
* Lightweight and optimized
* No .po/.mo files required
* Update-proof (translations stored safely in database)

Free version allows up to 3 languages.
Pro version unlocks unlimited languages: https://livelang.pro/pricing/

LiveLang is ideal for developers, agencies, and website owners who want full control over translations without complexity.

== Installation ==

1. Upload the plugin files to `/wp-content/plugins/livelang` or install via WordPress Plugins screen.
2. Activate the plugin.
3. Go to Settings → LiveLang Settings to configure languages.
4. Add the language switcher using shortcode, menu, or PHP.
5. Visit your frontend and click the “Translate” button to start editing.

== Frequently Asked Questions ==

= How do I use LiveLang? =
Enable Translate Mode from the frontend, click any text, edit it, and save instantly.

= How many languages can I use? =
The free version supports up to 3 languages. Pro version supports unlimited languages.

= Do I need separate pages for each language? =
No. LiveLang allows multiple languages within the same page.

= Is it SEO-friendly? =
Yes. LiveLang generates clean language-based URLs (example: /en/, /bn/) and adds proper lang attributes to HTML.

= How does the language switcher work? =
Use the shortcode [livelang_language_switcher] anywhere — posts, pages, menus, or PHP files using do_shortcode().

= Can I translate images? =
Yes. Media Translator allows you to display different images for different languages.

= Will translations be lost after updates? =
No. All translations are stored safely in the database and remain intact after updates.

= Does it slow down my website? =
No. The built-in JSON caching system minimizes database queries and ensures high performance.

== Screenshots ==

1. LiveLang Translate Mode on frontend
2. Inline text editing interface
3. Multi-language editing within the same page
4. Language switcher with flags
5. SEO-friendly URL structure
6. Media Translator for language-based images
7. Elementor editor compatibility

== Changelog ==

= 2.1.5 =

* Added Dropdown `<select>` & `<option>` Multi-Translator: hovering or clicking any `<select>` dropdown (such as WooCommerce shop sorting or custom selects) in the visual editor opens a dedicated Dropdown Translator popover. Edit all dropdown option choices at once in a single batch.
* Fixed Media Translation reload persistence: resolved an issue where image URLs containing digits/upload dates were mistakenly corrupted by number-normalization patterns (`::NUM::`). Image and upload URLs are now strictly excluded from number normalization and preserved as exact literal entries.
* Added automatic URL variation expansion for media entries: generates protocol (`http`/`https`), root-relative (`/wp-content/...`), relative, and unscaled base image variations so images match regardless of how themes or builders output them.
* Enhanced `srcset` & `sizes` attribute stripping: automatically removes responsive `srcset` and `sizes` attributes from translated `<img>` and `<source>` tags on both server and client side, preventing the browser from reloading original thumbnails.
* Full WordPress 7.0 compatibility and WordPress Coding Standards (WPCS) compliance updates across all plugin files and Freemius SDK modules.

= 2.1.4 =

* Added a fixed floating "Translation Active" indicator at the bottom right of the screen for better visibility when translation mode is enabled.
* Added a polished UI for the floating indicator, featuring a pulsating dot, sleek dark gradient background, and a rotate-on-hover close icon to easily deactivate translation mode.
* Enhanced compatibility by perfectly isolating the new floating indicator UI from active theme styles, ensuring consistent rendering across all WordPress themes.
* Added support for translating entire text blocks containing mixed inline HTML tags (e.g. `<strong>`, `<em>`, `<a>`, `<span>`) — previously, paragraphs with nested tags were silently skipped.
* Added support for translating multi-line text blocks containing `<br>` tags — any variation (`<br>`, `<br/>`, `<br />`) is now normalised before matching on both the server and client side.
* Fixed a PHP white screen caused by unescaped forward slashes in the `<br>` regex pattern — the delimiter is now `~` and all replacements are guarded against `null` return values from `preg_replace`.
* Added drag-and-move support to the floating "Translation Active" indicator — it can now be freely repositioned anywhere on the screen during a session. Position resets to the default bottom-right corner on page reload.

= 2.1.3 =

* Fixed a critical "Array to string conversion" PHP warning appearing on the frontend (particularly visible on WooCommerce cart and checkout pages) when any text translation was saved. The root cause was the `gettext`, `ngettext`, and `gettext_with_context` filter hooks returning raw arrays from the translation map instead of the expected translated string — a regression introduced when the map format was upgraded to carry alignment metadata alongside translated text. All three hooks now correctly extract the string before returning it.
* Fixed the same array-to-string warning being thrown by the REST API sanitize callbacks for the translation save endpoint (`/livelang-api/v1/save`). WordPress runs `sanitize_callback` before type validation, so if any parameter arrived as an array the core `sanitize_text_field` / `wp_kses_post` functions would trigger the warning before the plugin's own type guards could run. All five parameter callbacks are now wrapped in closures that coerce unexpected arrays to empty strings before sanitizing.
* Added custom alignment for translations. You can now set the alignment of the translated text to left, right, or center.

= 2.1.2 =

* Fixed a bug causing translated text to appear doubled on the frontend (e.g. an original of "Shop" translated to "Shop Page" would render as "Shop Page Page"). This happened because the client-side dynamic translation engine could run a second time over text the server had already translated, and — since the translated text often contains the original text as a substring — the matcher would match that substring and append the translation again.
* Fixed the same doubling from also occurring specifically right after saving an edit in the frontend editor: saving a translation bumped the client-side dictionary version (invalidating every "already translated" marker on the page) and then wrote the correct text into the DOM, which the MutationObserver picked up as new/untranslated content and re-translated. The editor now marks its own writes as already translated so they're never re-processed.
* Fixed the same doubling potentially affecting WooCommerce AJAX fragments (mini-cart, order review), which are already translated server-side before being injected into the page.
* Added proper per-element de-duplication for attribute translations (`placeholder`, `title`, `alt`, `aria-label`, `data-title`, `value`) on the client side, matching the de-duplication text nodes already had, so an unrelated DOM mutation elsewhere on the page can no longer cause an attribute to be translated on top of itself repeatedly.
* Fixed a remaining case of the "Shop" → "Shop Page Page" doubling bug: saving a translation via the frontend editor could still show the text doubled immediately after saving (though the correctly stored value would appear after a page reload). The editor was marking its own DOM write as "already translated" while the element still had `contenteditable="true"` on it, and that marker was being silently skipped (the client-side translator deliberately never touches elements currently being edited). The contenteditable attribute is now removed before the write is marked as translated, so the marker actually takes effect and the MutationObserver no longer re-translates it.

= 2.1.1 =

* Performance: rewrote the dynamic (client-side) translation engine — a single compiled regex + Map lookup replaces per-pair split/join loops, cutting translation-pass cost from O(pairs × text nodes) to a single O(text length) pass per node
* Performance: MutationObserver now scopes translation passes to actually-changed elements instead of re-walking the entire page on every update
* Performance: translation passes batch via requestAnimationFrame so rapid DOM updates (WooCommerce Blocks cart/checkout re-renders, quantity steppers) trigger one pass per frame instead of one per mutation
* Performance: text nodes already translated under the current dictionary are skipped on subsequent passes instead of being re-scanned
* WooCommerce: legacy AJAX cart/checkout fragments (mini-cart, order review) are now translated server-side, matching the same engine used for full page loads
* Fixed: translation precedence between global and page-specific entries was previously undefined when both existed for the same text; page-specific translations now reliably override globals
* Extended translatable attribute coverage to `value` (legacy submit/button inputs), `aria-label`, and `data-title`, both server- and client-side
* Fixed a serious bug: the "Flush Cache" button in System Maintenance shared its element ID with the destructive "Clear All Translations" action, meaning clicking what looked like a safe cache flush actually permanently deleted all translation data. These are now completely separate, correctly labeled, independently wired actions.
* Added a proper Danger Zone on the Translations screen: deleting data now requires explicitly choosing a scope (inactive only / page-specific only / global only / one language / everything) and typing DELETE to confirm — nothing can be triggered by a single accidental click anymore.
* Added a one-click "Export All as CSV First" backup option directly next to the Danger Zone.
* "Flush Cache" is now a real, safe, non-destructive action — it only invalidates cached translation lookups and never touches stored translation data.
* Deleting translation data can now be scoped (by status, by global/page-specific, or by language) instead of always being all-or-nothing.

= 2.1.0 =

* SEO: Added automatic hreflang alternate tags (+ x-default) for every configured language, generated straight from your live language list
* SEO: Added og:locale meta tag matched to the visitor's active language
* SEO: Fixed meta description, Open Graph, and Twitter Card "content" attributes not being translated — they now translate along with the rest of the page
* Admin UI: Added a stats overview (total strings, active strings, languages configured) to the Translations screen
* Admin UI: Added search, per-language filter, and status filter to the Translations table
* Admin UI: Added bulk actions (activate, deactivate, delete) with select-all support to the Translations table
* Frontend UX: Replaced jarring native alert() error popups with smooth, non-blocking toast notifications
* Fixed a markup bug where the pagination wrapper on the Translations screen was missing its closing tag
* Internal: translations list queries now share a single filter builder for consistent, safely-prepared SQL

= 2.0.4 =

* Fixed Elementor editor compatibility issues
* Added Media Translator for language-based images
* Improved multilingual image handling
* Enhanced compatibility with page builders
* Improved translation performance and caching
* Fixed minor bugs and improvements

= 2.0.3 =

* Made compatible with WooCommerce
* Added syncronization with WP Core Translations for mo file loading and translate automatically
* Added syncronization with WP Theme and Plugins translations files.

= 2.0.2 =

* Modernized Administrative Dashboard with premium full-width fluid layout
* Redesigned "Language Manager" with high-fidelity live preview and upward-opening dropdowns
* Implemented new "WOW" Pro Upgrade Modal with classic UI/UX patterns and smooth animations
* Hardened security across all administrative outputs using wp_kses and strict escaping
* Fixed critical early-initialization fatal error affecting plugins like WPForms
* Optimized admin menu icon size (16px) and alignment for global consistency
* Integrated native Freemius upgrade paths and removed legacy pricing sections
* Performed comprehensive code audit and removed unused build artifacts (.scss, .min.css)

= 2.0.1 =

* Added fully customizable Floating Language Switcher with real-time admin preview
* Added ability to enable/disable floating switcher from settings (Disabled by default)
* Implemented high-performance versioned caching for translations (O(1) search/replace)
* Hardened REST API security with strict language validation
* Refined frontend switcher logic with accessibility (Esc key) and click-outside detection
* Optimized translation mapping with versioning to avoid aggressive cache flushing

= 2.0.0 =

* Major UI/UX overhaul of the WordPress Admin Toolbar
* Added custom premium "Radio-style" switcher for enabling/disabling the editor
* Fixed language preservation issue when toggling the editor (stays on the current language)
* Improved toolbar responsiveness across desktop and mobile devices
* Refined dropdown styles for language switching
* Enhanced performance of the toolbar UI

= 1.0.3 =

* Remove language code from url for default language
* Fix language switcher URL generation for default language
* Improved compatibility with various themes and plugins
* Fixed minor bugs and improved overall performance

= 1.0.2 =

* Added full compatibility with Pro version (supports unlimited languages)
* Improved multi-language system stability and consistency
* Fixed number filtering issue in translations
* Added dynamic lang attribute (e.g., lang="en-US") to HTML tag for better SEO & accessibility
* Fixed inconsistencies between global and page-based translations
* Resolved REST API URL issues for subdirectory WordPress installations
* Improved translation handling logic
* Fixed multiple minor bugs and improved overall performance

= 1.0.1 =

* Added full multi-language support
* Added SEO-friendly language URL structure (domain.com/lang/slug)
* Added built-in language switcher
* Added language switcher shortcode
* Added shortcode support for menus and PHP theme files
* Added country flags for each language
* Added high-performance JSON translation cache system
* Improved frontend UX/UI performance
* Free version limited to 3 languages
* Fixed bugs from previous version

= 1.0.0 =

* Initial release
* Added visual inline translation editor
* Added page-based and global translation modes
* WooCommerce compatibility
* Database-based translation storage
