| 开发者 | sudosw |
|---|---|
| 更新时间 | 2026年8月1日 01:36 |
| PHP版本: | 7.4 及以上 |
| WordPress版本: | 7.0 |
| 版权: | GPLv2 or later |
| 版权网址: | 版权信息 |
[parly_switcher] shortcode.<html lang> attribute per page.parly_t(), parly_get_current_lang(), parly_get_original_id() and parly_is_translation() for themes that render content in custom templates./about-us/ instead of /en/sobre/). If your SEO strategy requires /en/-style URL structures, Parly is not the right tool.header.php, a footer credit, a button label inside a custom template) is outside the database. Parly offers two workarounds — the Theme texts scanner, which replaces registered strings in the rendered HTML of translated pages, and the parly_t() helper for developers who can edit the theme — but both require identifying each string. Themes that build entire layouts in PHP (custom front pages, heavily hardcoded designs) will need developer work with the helpers below, and in extreme cases a plugin with an automatic, external-service approach (such as Weglot) may fit better despite its subscription cost.function_exists() if your theme may run without Parly):
parly_t( array $translations ) — returns the string matching the language of the page being viewed. Example: echo parly_t( array( 'en' => 'About us', 'pt-br' => 'Sobre nós' ) );. Ideal for hardcoded template text a developer controls.parly_get_current_lang() — returns the language code of the page being viewed (e.g. 'en', 'pt-br').parly_get_original_id( int $post_id = 0 ) — returns the ID of the original (default-language) post of the translation group. Essential for custom templates: lets a theme render the same template parts for every language variant of a page (see the FAQ on homepages that render empty).parly_is_translation( int $post_id = 0 ) — whether the current (or given) post is a translation rather than the original.parly_duplicate_skip_meta — lets developers exclude additional meta keys from duplication when a translation is created.[parly_switcher] — renders the inline language switcher anywhere shortcodes are supported./wp-content/plugins/parly-simple-multi-language, or install through the WordPress plugins screen directly.Yes. Duplication copies all post meta, which is where page builders store their layouts, so each translation is edited with the same builder as the original. For AI bulk translation, note that builders like WPBakery and Divi keep visible text inside shortcodes (e.g. [nectar_split_heading text="..."]); Parly's export and prompt tell the AI to translate that text while preserving the shortcode structure. After importing a page-builder page, review it and, if a heading did not translate, open it in the builder and adjust — editing text where it actually lives is always the most reliable.
Yes. Create one menu per language in Appearance → Menus, then map them in the Menus tab (per theme location, per language). Parly swaps the menu automatically based on the language of the page being viewed.
Removing a language shows a confirmation screen listing every affected page. By default pages are moved to the trash (recoverable); you can optionally delete them permanently, which requires typing the language code to confirm.
Export generates a JSON file with your content and embedded instructions for the AI, plus a ready-to-paste prompt shown on screen. You attach the file to any AI chat, paste the prompt, and upload the returned JSON. Parly validates the file, repairs common formatting mistakes, and creates translations as drafts (or published, your choice). No API keys, no external calls — the plugin never contacts any server.
No. Parly makes no external requests. The AI translation step happens entirely outside the plugin, in whatever tool you choose. The site scanner only fetches pages of your own site.
One functional cookie (parly_lang, 30 days) may be set in two situations: when automatic browser detection is enabled (to make sure detection happens only once) and when a visitor manually picks a language in the switcher (to remember the choice). It contains only a language code and is never sent to third parties.
Two options. First, the Theme texts tab: scan a page, register the texts it finds, and Parly replaces them in the rendered HTML on translated pages — no theme changes needed. Second, for text a developer controls, the parly_t( array( 'en' => 'About us', 'pt' => 'Sobre nós' ) ) helper returns the string matching the language of the page being viewed. If a theme cannot be edited and the scanner does not reach the text, a plugin with a different (automatic, external-service) approach such as Weglot may fit better — different trade-offs, usually a paid subscription.
If your theme builds a page's content inside a custom template (for example front-page.php, or a page-home.php matched by the home slug), WordPress only uses that template for the original page. A duplicated translation has a different slug (e.g. home-2) and is not the configured front page, so it falls back to the generic page.php and, if the content field is empty, renders nothing.
Point the theme at the original page with parly_get_original_id(). In page.php (or wherever the branch lives):
$parly_id = function_exists( 'parly_get_original_id' ) ? parly_get_original_id() : get_queried_object_id();
if ( (int) get_option( 'page_on_front' ) === $parly_id ) { get_template_part( 'template-parts/home' ); return; }
Now every language variant reuses the same custom markup. Use parly_t() / parly_get_current_lang() inside that markup (or register the visible strings under Theme texts) so the reused template shows text in the current language. parly_is_translation() is also available if you only want to branch on translated views.
The switcher link for that language falls back to the site homepage. Unpublished (draft) translations are never linked.
No. Running two multilingual systems at once causes conflicts. Parly shows a notice if it detects one active, and you should use only one at a time.
.mo/.po language packs for the plugin's own admin UI (Brazilian Portuguese, Spanish, French, German), loaded via load_plugin_textdomain() so translations ship with the plugin instead of depending on WordPress.org's translation system.wp_kses_post() before saving, regardless of the importing user's unfiltered_html capability, since the file's contents originate from an AI/export round-trip rather than the editor UI.wp_template_enhancement_output_buffer), so core owns the buffer's lifecycle instead of the plugin.[parly_switcher] shortcode; menu integration (per-language menus, append to menu, and a native "Language switcher" menu item in Appearance → Menus); browser language detection; hreflang and per-page lang attribute; trilingual onboarding; Theme texts with a site scanner for text outside pages; AI bulk translation with a compact JSON export, ready-to-paste prompt, page-builder (shortcode) text handling, HTML/shortcode-structure validation and automatic Markdown repair; duplicate-import protection; and developer helpers (parly_t, parly_get_current_lang, parly_get_original_id, parly_is_translation).