• Resolved Jules Colle

    (@jules-colle)


    I have a site with French as the default language.
    My original text is: Je vais au "cinema"

    When I translate the page from French while previewing the page in French, the original text shows: Je vais au “cinéma”
    When I perform the translation here by changing the translated text to Dit is mijn vertaling. The translated text is saved to the database like this:

    original: Je vais au “cinéma”
    translated: Dit is mijn vertaling

    When I translate the page from French while previewing the page in Dutch, the original text shows: Je vais au ? cinéma ?. When I perform the translation here by setting it to Iets helemaal anders another entry is created in the database:

    original: Je vais au ? cinéma ?
    translated: Iets helemaal anders

    So the problem is that we can have 2 different translations for the same text in the database. Only the translation that is done on the Dutch page preview seems to work. Translations made from the base language (if the original text contain quotes) are never displayed on the frontend.

    I’ve been spending most of the day figuring out what is going on here, and I found the source of the problem. In the file translatepress-multilingual/includes/class-translation-render.php at line 1917 there’s the function fix_wptexturize_characters( $translated, $text, $context, $domain ). Inside this function at line 1940 there is this code:

    if( $default_language != $TRP_LANGUAGE && array_key_exists($context, $list_of_context_text) && in_array($text, $list_of_context_text) ){
        return trp_x( $text, $context, '', $default_language );
    }

    Seems like the trp_x function changes to ??, but as you can see, this function is only called when $default_language != $TRP_LANGUAGE, so only when we are visiting (or previewing) the page in Dutch.

    • This topic was modified 11 months, 3 weeks ago by Jules Colle.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Jules Colle

    (@jules-colle)

    In case others have the same problem, I used to trp_x filter to undo the changes made by trp_x:

    add_filter('trp_x', function($text, $original_text, $context, $domain, $language) {
        return $original_text;
    }, 10, 5);

    Hope this will not lead to other issues..

    Hello there,

    Thank you for reaching out to us about this!

    I will be replicating this issue on one of our instances and forward it to our team so we can get it solved as soon as possible.

    Once again we are grateful for describing this in such details to us, I might get back to you if I have any further questions.

    Best Regards,

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Bug with fix_wptexturize_characters’ is closed to new replies.