• Setup for debug reference:
    For instance, I have a Woocommerce product translation needs, to simplify the explanation, just focus on post content.

    For the theme rendering, it just use the Woocommerce default template with default WordPress function “the_content()” to render the post content(description).

    The default language is set to be zh_HK and the secondary language is en_US.
    Version: WP 5.8.3/TRP 2.1.8

    Step to reproduce:
    I tried by testing a small portion text in post content.
    The text is “雞手語戊卜視日木收許您,寫上海裏夕成實因戊山里抓,瓜坡示夏友三再兄比說浪事采遠手哪。冰那訴會林清十。到現乞反息七喝家多飛美文亭兔。”

    In the template, I wrap it with

    <div class="translation-block"> 
    <?php the_content(); ?>
    </div>

    In the editor preview(default language, zh_HK in this example), select the text to translate.
    The text appear to the box on the left hand side become.
    <p>雞手語戊卜視日木收許您,寫上海裏夕成實因戊山里抓,瓜坡示夏友三再兄比說浪事采遠手哪。冰那訴會林清十。到現乞反息七喝家多飛美文亭兔。</p>

    In the To English place, type ‘test’ and save the translation.

    Then I change the language on the left hand side dropdown box to English.
    The content supposed to be ‘test’ is untranslated. If trying to select the text to translate. Found that Translate Press recognise it as

    <trp-post-container data-trp-post-id='4918'><p>雞手語戊卜視日木收許您,寫上海裏夕成實因戊山里抓,瓜坡示夏友三再兄比說浪事采遠手哪。冰那訴會林清十。到現乞反息七喝家多飛美文亭兔。</p>
    </trp-post-container>

    Because there is an extra wrapper to the content, Translate Press did not translate it and recognise it as different text for translation.

    I wonder if it is an intended design or not. Not sure which one is intended but the inconsistency will confuse the end operator who update the content of the page.
    Because it is translated in Default Language but then untranslated in the target language.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter 西門 正 Code Guy

    (@simongcc)

    I found out the problem that in class-translation-render.php

    It adds the tag trp-post-container to the content output.
    It also adds to the preview page which should not be.
    So a simple fix should be changing the testing from

    if ( $TRP_LANGUAGE !== $this->settings['default-language'] )
    {
    // skipped...
    }

    to

    if ( $TRP_LANGUAGE !== $this->settings['default-language'] && !(isset( $_REQUEST['trp-edit-translation'] ) && $_REQUEST['trp-edit-translation'] == 'preview' ))
    {
    // skipped...
    }

    It will resolve the inconsistent behaviour. It could also avoid saving undesired strings to the database to bloat it up.

    I have tested it in TRP 2.1.8 and it works on the fly.
    AFAI understand, there should be no other concerns.
    Because Translate Press use the mechanism to scan the output buffer and replace the text on the fly, the tag is for its recognition for text translation.

    Thread Starter 西門 正 Code Guy

    (@simongcc)

    About my previous solution, it only works in preview, but then in frotnend, because there is an extra wrapper. It still not translate the text.

    Maybe there is some internal checking mechanism need to be reviewed for the trp-post-container, without this, the translation works properly.

    Hey there,

    Thanks for reaching out to us!

    We deeply apologize for the delayed response.

    There has been a great load on our support team in the past few days, but such a long reply time is very uncommon.

    I managed to replicate your mentioned issue and followed it to our development team.
    Until they manage to fix this, as a hotfix you can use Advanced TP Settings -> Disable post container tags for post content.

    Let me know if there is anything else I can help you with.

    Best Regards

    Plugin Support Alex

    (@alexcozmoslabs)

    Since it’s has been more than 5 days since you received instructions about the opened topic, and you did not return with an update, we will mark this ticket as successfully resolved.
    If you have other questions regarding TranslatePress, we recommend you create another ticket.

    Thread Starter 西門 正 Code Guy

    (@simongcc)

    Thanks for your solution. Hope it will be get fixed soon.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Report: Translation Block inconsistency’ is closed to new replies.