Beschreibung
Open any page on your site, click „Translate this page“ in the admin bar, choose a
target language, and either auto-translate every visible string (via a free
machine-translation service) or edit translations by hand while seeing the page
update live.
Saved translations are rendered server-side into the HTML response (SEO-friendly:
no flash of untranslated text, and hreflang alternates in the head), and visitors
switch languages via a link-based switcher (bottom-right).
Developed by Ricardo Sawir for Sawir Studio LLC.
- Website: https://sawirstudio.com
- X: https://x.com/RicardoSawir
- GitHub: https://github.com/sawirricardo
- Email: ricardo@sawirstudio.com
URLs use a language path prefix, e.g. /es/about for Spanish, /about for the source
language (which stays canonical, un-prefixed). Language is resolved in this order:
/es/ path ?lang=es saved cookie browser Accept-Language source. Root and
prefix-less URLs auto-detect the visitor’s browser language without redirecting
(a Vary header is sent so shared caches behave).
- Settings Live Translate: set your source language and tick the languages to offer.
- Visit a front-end page and click „🌐 Translate this page“ in the admin bar.
- Pick a language, hit „Auto-translate empty“ (or edit strings), then „Save“.
- Visitors use the switcher (bottom-right); each language has its own /xx/ URL.
Note: language path prefixes assume a root-domain install and no top-level page
whose slug is a two-letter language code.
External services
This plugin’s optional „Auto-translate“ feature (admin-only, triggered manually
by clicking an Auto-translate/Translate button) sends the source text strings
and the chosen language pair to the MyMemory translation API
(https://mymemory.translated.net/) to fetch machine translations. The request
is made from the administrator’s browser only when they click the button; no
visitor data is ever sent, and nothing is sent automatically.
- Service terms: https://mymemory.translated.net/doc/en/tos.php
- Privacy policy: https://mymemory.translated.net/doc/en/privacy.php
Developers can swap the provider — see „Custom translation provider“ below.
Native WordPress localization (dates, core/theme strings)
On a translated request the plugin switches WordPress’s locale to the target
language, so dates (month/day names) and any installed core, theme, and plugin
translations render natively — the string map only covers the rest.
For this to have visible effect the language pack must be installed. The easiest
way is Settings General Site Language: pick and save the language once (which
downloads its pack), then switch back to your source language. Languages without
an installed pack still work for content translation; only native dates/strings
are skipped. Map codes to custom WP locales with the ’sawir_lt_wp_locale‘ filter.
Scan site for strings
Settings Live Translate „Scan site now“ crawls your published pages, posts,
and public archives to discover every translatable string up front (batched, with
a progress indicator). Discovered strings then appear in the „Edit all site
strings“ section right below, where you can pick a language and translate, auto-
translate, or bulk-import the whole site at once instead of page by page. Note:
machine translation is still rate-limited by the free service, so for large sites
use Bulk edit to export and translate elsewhere.
Multisite
Multisite-aware. Each subsite has its own settings and its own translations table,
configured independently. Tables are created on network activation, when a new
subsite is created, and lazily on first admin visit; uninstall cleans every site
on the network.
Custom switcher
Turn off „Built-in switcher“ in settings and render your own anywhere in your
theme using sawir_lt_switcher_links(), which returns the language links for the
current page:
<?php if ( function_exists( 'sawir_lt_switcher_links' ) ) : ?>
<ul class="my-lang-switcher">
<?php foreach ( sawir_lt_switcher_links() as $l ) : ?>
<li>
<a href="<?php echo esc_url( $l['url'] ); ?>"<?php echo $l['active'] ? ' aria-current="true"' : ''; ?>>
<?php echo esc_html( $l['name'] ); ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
Each item is [‚code‘,’name‘,’url‘,’active‘,’is_source‘] (code is “ for the
source language). sawir_lt_current_lang() returns the active language code.
Custom translation provider
Auto-translate uses the free MyMemory API by default. To use your own provider
(DeepL, Google, a local model, …), reassign window.SawirLT.translate from a
script enqueued after the ’sawir-lt-walk‘ handle. Signature: it receives the
source text and the two language codes, and returns a Promise resolving to the
translated string. Every auto-translate path (in-page editor and admin bulk
translate) routes through it.
add_action( 'admin_enqueue_scripts', 'myprefix_lt_provider' );
add_action( 'wp_enqueue_scripts', 'myprefix_lt_provider' );
function myprefix_lt_provider() {
if ( wp_script_is( 'sawir-lt-walk', 'registered' ) ) {
wp_enqueue_script( 'myprefix-lt-provider',
plugins_url( 'provider.js', __FILE__ ),
array( 'sawir-lt-walk' ), '1.0.0', true );
}
}
provider.js:
window.SawirLT.translate = function ( text, source, target ) {
return fetch( 'https://example.com/translate', {
method: 'POST',
body: JSON.stringify( { text: text, from: source, to: target } )
} ).then( function ( r ) { return r.json(); } )
.then( function ( j ) { return j.translation; } );
};<h3>Translations</h3>
The plugin’s own admin/UI text is translation-ready (text domain
„sawir-live-translate“). A .pot template ships in /languages — drop your
.po/.mo there or under wp-content/languages/plugins/. (The in-page editor’s
JavaScript labels are not yet localized.)
Other plugins by Sawir Studio
- Sawir Restock Notifier for WooCommerce — let customers request an email when an out-of-stock product is back.
- Sawir Product Image Zoom for WooCommerce — product image lightbox with navigation and click-to-zoom.
- Sawir Variation Gallery Tools for WooCommerce — manage variation-specific gallery images.
- Sawir Role Capabilities Manager — create custom user roles and manage capabilities.
- Sawir Media Folders — organize the Media Library into fast, unlimited folders with drag & drop.
Installation
- Install and activate the plugin, then go to Settings Live Translate.
- Set your Source language — the language your site is written in.
- Tick every Target language you want to offer visitors, adjust the
switcher style if you like, and click Save.
Optional: for translated dates and built-in theme text to switch too, install
the language pack once via Settings General Site Language (pick the
language, save, then switch back). Content translation works without it.
Translate a page
- While logged in, visit any page on the front end and click
🌐 Translate this page in the admin bar. - In the panel, pick the target language.
- Click Auto-translate empty — every visible string is machine-translated
and the page updates live. You can also type or fix any translation by
hand; click a source string in the panel to highlight it on the page. - Click Save. Everything before saving is only a preview in your own
browser. Wait for the status line to say „saved N translations ✓“. - Verify under Settings Live Translate Saved translations: your language
should be listed with a string count. If it isn’t, nothing was saved — go
back and Save again.
Translate the whole site at once
- Settings Live Translate „Scan site now“ crawls your published pages and
collects every translatable string. - In „Edit all site strings“ below it, pick a language, click Load strings,
then Auto-translate empty (or Bulk edit), and Save.
Auto-translate uses a free service with a daily limit. If it stops with a
„limit reached“ message your progress is kept — Save, and continue later. Or
use Bulk edit to copy all strings as JSON, translate them anywhere (a paid
service, AI, a human translator), paste back, Apply, and Save.
FAQ
-
I switch languages but nothing changes
-
Almost always this means no translations are saved for that language yet.
Check Settings Live Translate Saved translations — if the language isn’t
listed (or shows 0 strings), open the page editor again, auto-translate, and
click Save. The live preview in the editor is not saved until you do. -
Some strings stay untranslated
-
The in-page editor only sees strings on the page you opened. Text that lives
on other pages needs those pages translated too — or run the site-wide scan.
Strings injected by sliders/scripts after page load may need a manual entry
via „Edit all site strings“. -
I edited my content and its translation disappeared
-
Translations are matched to the exact original text. If you rewrite a
sentence, translate the new version once and save. -
Does it work with caching plugins?
-
LiteSpeed Cache is supported out of the box (pages are varied per language
cookie). For other page caches, exclude or vary on the sawir_lt_lang cookie,
and purge the cache after saving translations. -
Can I hide the floating switcher and use my own?
-
Yes — untick „Show the built-in language switcher“ in settings and render
your own with sawir_lt_switcher_links(); see „Custom switcher“ below.
Rezensionen
There are no reviews for this plugin.
Mitwirkende & Entwickler
„Sawir Live Translate“ ist Open-Source-Software. Folgende Menschen haben an diesem Plugin mitgewirkt:
MitwirkendeÜbersetze „Sawir Live Translate“ in deine Sprache.
Interessiert an der Entwicklung?
Durchstöbere den Code, sieh dir das SVN Repository an oder abonniere das Entwicklungsprotokoll per RSS.
Änderungsprotokoll
1.1.0
- Fix: language switching could get stuck on one language behind LiteSpeed Cache — cached pages are now varied per language cookie (X-LiteSpeed-Vary header + litespeed_vary_cookies filter).
1.0.1
- Add links to other Sawir Studio plugins.
1.0.0
- Initial release.