| 开发者 | alexgeorgiev |
|---|---|
| 更新时间 | 2026年12月4日 16:44 |
| PHP版本: | 8.1 及以上 |
| WordPress版本: | 7.1 |
| 版权: | GPL-2.0+ |
| 版权网址: | 版权信息 |
/en/), subdomain (en.example.com), per-language domains, or query-parameter (?lang=en) modes; auto-detect from URL, cookie, browser, or an edge/CDN hint.l10n.php) or database-mode, with CLDR plural rules (6 forms for Arabic, 3 for Russian) and context support. The site title and tagline appear there toodata-nosnippet wrapper when a page shows content in another language as a fallback, and optional Speculation Rules prerendering and View Transitions when a visitor switches languages.
Integrations
Each integration loads when the plugin or theme it is for is active: WooCommerce, Elementor, Beaver Builder, Bricks, Oxygen (Classic and 6), ACF, Meta Box, Pods, Gravity Forms, WPForms, Contact Form 7, Yoast SEO, Rank Math, AIOSEO, SEOPress, The SEO Framework, Slim SEO, and the Blocksy, Kadence and Neve themes.
For developers
More than 200 action and filter hooks, a REST API, WP-CLI commands and a documented addon system. A PHP helper API lets you translate a string or run a piece of your own code in a chosen language. Classes and methods marked @api do not change in a breaking way within 1.x. Works on multisite. Full docs at perflocale.com/docs.
Try it without installing anything. Open a throwaway WordPress site in your browser with PerfLocale already active: Open PerfLocale in WordPress Playground
Where to go next
/de/ (the default), de.example.com, per-language domains, or ?lang=de.[perflocale_switcher] shortcode, or a menu under PerfLocale → Settings → Language Switcher./de/?p=123). If your server does not pass unknown paths to WordPress, use the query parameter URL mode (?lang=de)..htaccess, so add one rule that blocks direct access to exports: see Production tuning. Site Health shows whether you need it.wp-config.php constants, such as PERFLOCALE_DEEPL_API_KEY. See API keys.It adds some work to each page, as every multilingual plugin does, and it is written to keep that work small. It loads only the code a request needs, reads the data of a page's posts together, and keeps what it looked up in memory for the request. Between requests it uses your persistent object cache (such as Redis) or, without one, transients. Larger sites - many translated posts across many languages - benefit from a persistent object cache. PerfLocale works with page-cache plugins (WP Super Cache, W3 Total Cache, LiteSpeed Cache, etc.); cached pages already include the translated output from the request that filled the cache. Real-world page speed depends mostly on your theme, hosting, and other plugins.
Yes. You can translate products, variations, categories and attributes. Inventory (stock, SKU, GTIN, price, weight, dimensions) stays in sync across language variants whenever WooCommerce saves a product, whether the change comes from an order, the product editor, Quick Edit, the REST API, an import, or another plugin. Prices can be shown in several currencies, with exchange rates from the European Central Bank's daily reference rates or from a provider your site registers through a filter. Order emails are sent in the customer's language, and the mini-cart, cart and checkout use the visitor's language.
Yes. PerfLocale integrates with Elementor, Beaver Builder, Bricks Builder, Oxygen Classic, and Oxygen 6.0. Each builder's content is registered as translatable meta, and dedicated Language Switcher widgets/elements are provided for Elementor, Beaver Builder, and Bricks - in Oxygen (Classic or 6.0) use the [perflocale_switcher] shortcode in a Code Block or Shortcode element.
Yes. It is off by default. Tick Templates and template parts under Site parts at PerfLocale → Settings → Translation and the block templates and template parts you edit in the Site Editor - header, footer, 404, archive layouts - become translatable like any other content, along with the patterns, navigation labels and post content embedded in them. A translation only takes effect once you publish it. WordPress renders an empty region for a template part it cannot resolve, so a half-finished header would leave a blank strip across the site; until the translation is published, visitors keep seeing the original. The Site Editor's own Translations panel shows which languages exist and labels anything still in draft.
It depends on which kind of pattern you used, and the two look identical in the editor. A pattern you insert from the inserter is copied into the page, so its text is simply part of that page - translate the page under PerfLocale → Translations and the text comes with it. (This is also why the theme's pattern strings on the Strings screen don't apply to it: those are used when the theme renders the pattern file itself, while the copy in your page is plain HTML.) A synced pattern is stored once and the page only holds a reference to it, so there is nothing in the page to translate. Tick "Synced patterns" under Site parts at PerfLocale → Settings → Translation, then translate each pattern like any other post; PerfLocale serves the right one per language, including patterns nested inside a Group. Block-theme menus work the same way. Menu link addresses are already translated without any setting; enable "Navigation menus" in the same place to translate the visible labels too. In both cases, if a translation is missing or still a draft the original renders - never a blank space.
Go to PerfLocale → Strings and translate them like any other string - they are listed there as "Site Title" and "Tagline". There is nothing to switch on, and no scan to run: they are registered automatically when the plugin is updated or activated. Your original title and tagline are never overwritten. PerfLocale serves the translated text on the front end only, and refuses any attempt to write a translated value back over the original.
Yes. PerfLocale includes built-in migration tools for all three plugins. PerfLocale refuses to run while WPML, Polylang or TranslatePress is active, so deactivate the old plugin first - its data stays in the database - then go to PerfLocale → Settings → Export & Import and use the Migration section. Migrations run in batches and leave the old plugin's data untouched. An import that stops part-way can be run again: translations already imported are reused, not duplicated. Back up your database before a large import.
Yes. PerfLocale detects the text direction from the language configuration and sets the correct dir="rtl" attribute on the HTML element. PerfLocale's own stylesheets, for the language switcher and the admin screens, have right-to-left versions for languages such as Arabic and Hebrew.
Yes. Page-cache plugins such as WP Super Cache, W3 Total Cache, LiteSpeed Cache and WP Rocket work with PerfLocale, because each language version has its own URL and so its own cache entry. Any response whose language was decided by something other than the URL - a GeoIP or browser-language redirect, a returning visitor's language cookie - is sent with WordPress' no-cache headers (nocache_headers()), so a cache that respects them does not store one visitor's language and serve it to everyone. On an edge or server cache (Varnish, nginx fastcgi_cache) make sure Cache-Control is honoured or those responses are excluded. Note that enabling GeoIP / browser redirection makes default-language entry URLs uncacheable by design - a page cache serving them from cache would skip the redirect entirely; if you need both, use the bundled edge worker (assets/js/edge-helper.js) to route at the CDN instead. In cookieless mode those redirects do not run, so the default-language entry URLs stay cacheable.
Yes. Each site in the network has its own languages and translations. PerfLocale's in-memory caches are kept per site and are reset when code switches from one site to another.
Yes. PerfLocale reads each machine-translation API key from these sources, in this order, and uses the first one that has a value: an environment variable, a wp-config.php constant, a key saved under Settings → Connectors (WordPress 7.0 and later; DeepL, Google, Microsoft and LibreTranslate), then the PerfLocale setting. Set PERFLOCALE_DEEPL_API_KEY, PERFLOCALE_GOOGLE_API_KEY, PERFLOCALE_MICROSOFT_API_KEY, PERFLOCALE_LIBRE_API_KEY, PERFLOCALE_LIBRE_URL, PERFLOCALE_AGENCY_URL or PERFLOCALE_AGENCY_API_KEY in your container env or wp-config.php and the admin-side fields become read-only, showing which environment variable or wp-config.php constant supplies the value. With an environment variable or a constant, database backups, exports and SQL dumps do not contain the key.
By default nothing is lost: uninstalling removes the plugin's roles, capabilities, and scheduled tasks, but keeps all translations, languages, and settings in the database so a later re-install picks up exactly where you left off. If you want a complete removal instead, enable "Delete all plugin data when uninstalling" in PerfLocale → Settings → Advanced before uninstalling - then every plugin table and option is deleted. On an object cache that cannot clear groups, PerfLocale's cached copies expire on their own within a day, or within the GeoIP cache time you set. Your posts and pages (including translated ones) are always preserved as normal WordPress content.
On a multisite network each site's own choice is applied to that site, and your users' PerfLocale screen preferences, which every site shares, are removed only if no site chose to keep its data. Deleting the plugin from a very large network can run out of PHP execution time before every site is done: PerfLocale stops cleanly between sites, logs how many were purged and how many remain, and records where it stopped. Re-install the plugin and delete it again without activating it and the next pass carries on from there; from WP-CLI, wp plugin uninstall perflocale has no time limit and finishes the network in one pass. If a site fails, the log names it and the same steps retry it once the cause is fixed.
When you enable Edge Worker Integration (PerfLocale → Settings → Advanced), the plugin publishes one public REST endpoint that edge runtimes (Cloudflare Workers, Vercel Edge, Netlify Edge, AWS Lambda@Edge) can read to route visitors before the request reaches WordPress:
GET /wp-json/perflocale/v1/config - returns the routing and language data an edge worker needs: active language slugs and locales, URL mode (subdirectory / subdomain / domain / query), URL prefix type, default language, hide-default-prefix flag, excluded paths, detection and redirect order, home path, plugin version, and the edge-hint header name (X-PerfLocale-Lang) and cookie name. Response includes Cache-Control: public, max-age=300, s-maxage=3600, stale-while-revalidate=86400 plus an ETag so edges and browsers can revalidate cheaply with If-None-Match (304 on hit). When code hooks the permission filter described below, or the caller is logged in, the response is sent with Cache-Control: private, no-store instead.perflocale/api/config filter, keep it that way.
To restrict access (private staging sites, IP allowlists, Application-Password authentication, mTLS at a reverse proxy), hook the perflocale/edge_worker/config_permission_callback filter and return false or a WP_Error for requests you do not allow. Example:
add_filter( 'perflocale/edge_worker/config_permission_callback', fn () => current_user_can( 'manage_options' ) );
PerfLocale has no token or header scheme of its own. Use WordPress' own methods (Application Passwords for server-to-server requests, cookie and nonce for browser sessions, or a JWT/OAuth plugin) and check them in this filter, so the endpoint uses the same authentication as the rest of your site's REST API.
Please report security bugs found in the source code of the PerfLocale plugin through the Patchstack Vulnerability Disclosure Program. The Patchstack team will assist you with verification, CVE assignment, and notify the developers of this plugin.
perflocale/mt/trusted_hosts filter (a local or Docker endpoint); whitespace-only text is never sent; resuming a stopped bulk run keeps a translation someone edited in the meantime and reports it; a failed call names the item and its length; a short Chinese, Japanese or Korean title or excerpt is saved with a warning.POST /xliff/import answers 202 with a job id), continues after an interruption, keeps a draft an interrupted import left and lists it in the import's messages instead of deleting it, and keeps a failed import's file so Retry works; the Strings screen saves only the cells you changed, a person's edit replaces a machine translation made since the page opened, and another person's change is reported instead of overwritten; a .po export includes every plural form, so exporting and importing a file keeps all translations.wp perflocale health-check reports string links without a translation; creating a draft or pending post through the REST API with a slug no longer fails._doing_it_wrong notice; switcher() and [perflocale_switcher] take include, exclude and untranslated_link; new flag_emoji(), wp perflocale jobs run, and filters for External Agency batches and XLIFF staging limits; perflocale/updated can run again after a failed update, so listeners must be idempotent; a filter that returns the wrong type is ignored and reported.perflocale()->addon()) and JavaScript hooks for the language switcher, the block editor and the Jobs, Strings and Translations screens.wp perflocale health-check lists links a string import replaced and gives each string a translation group of its own.wp perflocale damaged-blocks finds translations damaged earlier.wp perflocale stock-drift check for WooCommerce stock.