Bug with fix_wptexturize_characters
-
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 toDit 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 toIets 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 functionfix_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.
- The topic ‘Bug with fix_wptexturize_characters’ is closed to new replies.