跳到正文
DEV Community· Mahdi JabinPour·· 3 小時前AI 評分54

WPML 與 Elementor 翻譯未更新:先查明原因再重新翻譯

WPML Translations Not Updating in Elementor: Find the Cause Before Retranslating

AI 導讀

文章提供 WPML 與 Elementor 翻譯未更新的排查流程,建議先核對來源與目標頁面 ID、文字所屬 widget 及翻譯工作,再檢查目標文件、模板關係和前端快取。

正文

Originally published on LumoWP.

You change a heading in Elementor, finish the translation, and open the French page. The old heading is still there. So you send the page for translation again. Sometimes that helps. Sometimes it changes nothing—and sometimes it replaces a layout someone carefully customized.

Before paying for another translation or clearing every cache on the site, find out which document and which layer still contain the old text. A page body, a reusable Elementor template, a dynamic field and a cached HTML response can all produce the same symptom. They need different fixes.

The short answer

Confirm the source and target page IDs, locate the widget that owns the text, check whether that field reached the translation workflow, and inspect the saved target. Only then decide between updating a translation, correcting a template relationship or clearing cached output.

This investigation combines official WPML and Elementor documentation with a review of WPML 4.7.4, Elementor 4.2.0 and Lumo AI Translator 3.20.28 source code. We also ran eight isolated tests against the Lumo extractor and path-writing methods. These are version-specific source findings and controlled data tests, not a claim that we reproduced every production failure or ran a paid AI translation end to end.

Five checkpoints for Elementor translations that do not update: source, extraction, target, template and cache

Follow the update through five layers before repeating the translation.

1. Identify the symptom before changing anything

Start with one affected URL and one sentence you can recognize. Record the source page ID, target page ID, language, widget type and expected text. If the problem affects a header, record its template ID too. This small record stops a surprisingly common mistake: updating a page while looking at a reusable component supplied by a different document.

What you observe What to inspect first What to avoid initially
Target editor and public page both contain old text Extraction, translation status and the saved target document Repeated cache purges
Target editor is correct; public URL is old Exact URL, template selection and cached output Deleting the translation
Body changes, but header or footer does not The separate Elementor template and its language relationship Retranslating the page body
One custom widget never appears in the translation job Widget registration and supported fields Replacing the AI provider
A manually redesigned language page changes back Which editor or process owns the target layout Running another source-based job
Only logged-out visitors see the old content Page cache, CDN and language-specific cache behavior Assuming a correct admin preview proves public delivery

Back up the affected content before a write operation. For an Elementor page, a plain copy of its visible text is not a complete backup: layout data and related metadata matter. Use your normal staging and backup workflow, and keep the first test limited to one language.

2. Understand where Elementor actually stores the page

The important discovery in the source is that checking WordPress post_content alone is insufficient. Elementor's document class defines _elementor_data as its document-data meta key. That JSON contains the element tree, widget settings and nested elements used by the builder.

WPML's Elementor integration also identifies _elementor_data as the relevant field. In class-wpml-elementor-data-settings.php, get_node_id_field() returns id. The integration additionally handles Elementor-specific metadata and invalidates copied CSS state in its own workflow.

WPML Elementor source identifies _elementor_data and the element id field

Condensed source excerpt from WPML 4.7.4; the surrounding explanation distinguishes page data from template selection.

That gives us a useful investigation order: source document → extracted fields → target document → selected template → rendered response. A translated paragraph appearing in a database field does not prove that the visible widget is reading it. Likewise, correct body data does not prove that the correct translated header has been selected.

Optional developer check: confirm the target without modifying it

The following diagnostic is intended for an administrator with WP-CLI access. Save it as a temporary local PHP file and run it with wp eval-file audit-elementor.php from the intended WordPress installation. Replace 123 and fr. Do not paste it into a public template or make a public diagnostic endpoint.

<?php
if (!defined('WP_CLI') || !WP_CLI) {
    exit;
}
if (!defined('ICL_SITEPRESS_VERSION')) {
    WP_CLI::error('WPML is not active.');
}
$source_id = 123;
$language  = 'fr';
$post_type = get_post_type($source_id);
if (!$post_type) {
    WP_CLI::error('Source post does not exist.');
}
$target_id = apply_filters(
    'wpml_object_id', $source_id, $post_type, false, $language
);
if (!$target_id) {
    WP_CLI::error('No linked translation found.');
}
foreach ([$source_id, (int) $target_id] as $id) {
    $raw = get_post_meta($id, '_elementor_data', true);
    $tree = is_string($raw) ? json_decode($raw, true) : null;
    WP_CLI::log(wp_json_encode([
        'id' => $id,
        'status' => get_post_status($id),
        'elementor_data_is_array' => is_array($tree),
        'top_level_elements' => is_array($tree) ? count($tree) : null,
        'duplicate_of' => (int) get_post_meta(
            $id, '_icl_lang_duplicate_of', true
        ),
    ]));
}

The return_original_if_missing parameter is deliberately false: a missing translation should not silently fall back to the original. See the official wpml_object_id reference for the argument order. The output checks identity and data presence; it does not prove translation quality, nested-field completeness or correct frontend rendering. A duplicate marker is a reason to investigate synchronization, not an invitation to delete metadata manually.

3. Check whether the missing text reached the translation job

Open the source page and locate the affected widget. Confirm the change was saved, then inspect the appropriate WPML translation job. Is the changed sentence present there? If it is absent, translating the available strings more accurately will not solve the missing-field problem.

For third-party or custom widgets, field registration matters. WPML documents registration through wpml-config.xml and, where appropriate, the wpml_elementor_widgets_to_translate filter. Repeater fields need their actual structure handled; a widget being visible in Elementor does not mean every setting is automatically translatable. See WPML's custom Elementor widget integration guide.

Dynamic content needs a separate question: where does this value originate? A product field, an ACF field or a linked reusable template may supply the visible text. Translate or configure that source through its supported workflow. Editing the surrounding heading cannot repair an unrelated dynamic value.

If the changed text is present in the job, review and complete that specific translation, then reopen the target page. If delivery remains pending or errors appear, collect the job status, affected IDs and relevant error details. Do not reset all translation jobs merely because one page is stale. Also check the affected version before applying a workaround from an old support thread.

4. Decide who is allowed to change the translated layout

Two legitimate workflows are easy to mix up. In one, the translation follows the original page's structure. In the other, someone deliberately maintains a different design for each language.

WPML's different-designs documentation warns that using the Translation Editor or automatic translation can replace a custom target design with the source layout. Choose the workflow deliberately instead of alternating editors whenever the page looks wrong.

For a manually maintained language version, check the per-page editor selection and whether it remains a synchronized duplicate. Our guide to different Elementor designs per language walks through that setup. An independent translation also needs independent maintenance: an English copy change will not necessarily become a French edit automatically.

Do not confuse “not updating” with “intentionally independent”

If your team chose a separate French layout, the correct action may be to update that French document manually. Rebuilding it from the English structure is a different operation, with different consequences.

5. Treat headers, footers and reusable templates separately

If the main content translates but a navigation label remains English, stop resubmitting the page. Identify whether the label belongs to a menu, a header template, a saved section or a dynamic source. Then open that actual component.

For Elementor Pro Theme Builder, WPML has a documented language-template relationship procedure. It sets the display conditions on the original template and connects a secondary-language template without an additional set of conditions. Follow that procedure for the relevant template type; do not assume another theme builder uses the same rules.

After connecting or updating a template, test a real page where it should appear. A correct template preview only proves that the template can render. It does not establish that the public page selected it.

6. Clear caches only after the stored translation is correct

Suppose the correct target document contains the new French heading, but visitors still receive the old heading. Now caching is a useful line of investigation. Confirm the exact public URL and language first. Then clear the affected page-cache and CDN entries using the tools provided by your stack, and compare a fresh logged-out request.

For generated Elementor files and data, use Elementor's supported Clear Files & Data tool. The menu location varies between releases; the official instructions show the current interface. This does not translate missing strings or repair a wrong language relationship.

There is a useful source detail here: Elementor 4.2.0's core/files/manager.php::clear_cache() removes generated files and metadata including document element-cache data, then fires its clear-cache hook. Its scope is broader than a single CSS file. Whether your page-cache or CDN integration also purges content depends on that integration; do not assume every cache layer was cleared.

If the target's stored JSON still contains the old wording, a cache purge cannot create the missing translation. Return to extraction, job completion or the process writing the target.

7. What our source tests found in Lumo's Elementor Bulk workflow

Lumo AI Translator has a dedicated Bulk Tools → Elementor Templates section. That is relevant when the stale content belongs to an Elementor document rather than a generic WordPress title. But the implementation deserves a closer look before pressing Translate & Save.

We extracted two method bodies from version 3.20.28 into an isolated PHP fixture, changing only their visibility so the test could call them. No WordPress records were modified and no AI API was called. All eight checks passed their stated expectations—including checks that deliberately demonstrate limitations.

Controlled input Observed behavior Practical meaning
A normal settings.title value Extracted with its indexed path Standard supported fields can enter the workflow
A custom settings.promo_copy value Not extracted Arbitrary custom settings are not automatically covered
Common editor field with 499 ASCII bytes Extracted Below this branch's length gate
Same field with 500 ASCII bytes Not extracted Retrying the same scan does not remove the gate
250 two-byte accented letters Not extracted strlen measures bytes, not visible characters
Existing matching target path Updated The basic setter works for that fixture
Missing target path Setter returns false Some fields can fail to apply
Existing path pointing to a different element ID Updated anyway A successful write is not an identity check

These findings apply to the Bulk Elementor extractor, not every translation route in the plugin and not WPML's own editor. The source also contains separate handling for certain menu and icon-list structures. The common-field length gate should not be generalized to every branch.

Why the last test matters

The extractor records paths such as 0.settings.title. The setter follows those array keys using isset; it does not verify the Elementor node's id. If the target layout has been reordered, index zero can now belong to another widget. The path still exists, so the write can succeed while reaching the wrong element.

Source-code diagram showing an indexed translation path reaching a different Elementor widget after reordering

Two source lines plus an explanatory comment. Our isolated fixture confirms that this setter does not compare element IDs.

That is why translations_applied is a write count, not a translation-quality score. Compare element identity, position and meaning when source and target layouts differ. For independently redesigned pages, manual editing or an explicitly compatible workflow is safer than assuming indexed paths still match.

The two modes also differ in the reviewed handler. Re-translate existing template begins with target Elementor data, but falls back to source data if the target data is empty or invalid. Create new translation begins with source data and may reuse an already linked target. Its label does not guarantee a separate new draft. When it creates a target, the reviewed code sets its post status to published.

The creation branch also writes duplicate-related metadata. We did not run a full later-source-save synchronization test for that branch, so we do not claim how every WPML configuration will behave afterward. Check the resulting translation relationship and duplicate state, and perform a controlled later source-save test on staging before adopting it for independently maintained layouts.

8. Use Bulk Tools for the right job, with a one-language check

Once you have established that an Elementor template actually needs translation, Lumo AI Translation Addon for WPML provides a dedicated workflow. This is our product, and its Bulk tools are distinct from WPML's own Translation Editor.

Step 1: verify the source and preserve the target

Keep a recoverable copy of the affected template and its language version. Confirm which one is the original and whether the target has a custom structure. Do not use a production-wide operation as the first diagnostic test.

Step 2: open Bulk Tools → Elementor Templates

Choose the correct Source Template. In the reviewed source, the picker considers Elementor library items, pages and posts with _elementor_data, then applies source-language filtering. If a document is missing, investigate its type, language relationship and picker filtering rather than duplicating it to force it into the list.

Step 3: choose the mode deliberately

Use Re-translate existing template only after identifying the intended linked target and assessing its structure. For Create new translation, remember the existing-target and published-status behavior described above. Start on staging and select one target language instead of All Languages (Auto).

Step 4: scan before translating

Click Scan Source Template and inspect Found Texts. Look for the exact stale heading, label or sentence. If it is absent, stop and investigate extraction. Another model or another paid request cannot translate a field that was never included.

Step 5: translate, save and verify the actual result

After Translate & Save, check the returned target, applied counts and public language URL. Review links as well as labels, especially menu items. Test mobile layout and the relevant header/footer assignment. Then make one controlled source change on staging and check what the next update does to the target.

Provider configuration is a separate prerequisite; our own API key setup guide covers that part. It should not distract from diagnosing an incorrect document, missing field or stale cache.

Lumo AI Translator Bulk Tools interface with callouts identifying the Elementor Templates tab

Annotated product screenshot showing where to open Elementor Templates. The screenshot itself has Selected Posts active; it is navigation guidance, not a completed translation test.

9. A useful handover is evidence, not “we cleared the cache”

Before closing the issue, keep a short record that another editor can follow:

  • The source and target IDs, language and affected template, if any.
  • The exact field that was missing or stale and where it is stored.
  • The workflow allowed to maintain the target layout.
  • The operation that corrected the problem, with a recoverable before-state.
  • The verified public language URL, including a logged-out check.
  • A result for one later source update, if synchronization is part of the workflow.

The next time a translated heading stays old, you should be able to say where the update stopped. That is a much better maintenance strategy than translating the whole page again and hoping the right layer changes.

Source notes and scope

The local code review covered WPML's class-wpml-elementor-data-settings.php, Elementor's core/base/document.php and core/files/manager.php, and Lumo's includes/admin-tab-bulk-tools.php, extract_elementor_texts(), ajax_translate_elementor_template() and set_nested_value(). The test fixture exercised extraction and nested-array writes only. The product image is an annotated version of the published product screenshot, not evidence of a fresh successful translation job.

Menu labels, limits and implementation details can change between versions. Compare your installed release with the versions stated above. The official documentation linked beside each procedure is the reference for its supported workflow; the source observations explain the behavior of the specific copies we examined.

來源:DEV Community · dev.to