Poedit and WordpPress: unwanted result in the translation of HTML tags

117 Views Asked by At

I have to translate some sections of a WordPress theme and I am faced with a difficulty, in practice:

The php source is the following

jQuery( '.login.login-action-lostpassword.bb-login #login > p.message' ).html( '<?php _e( '<div>Forgot your password?</div><p class="message">Please enter your email address. You will receive an email with instructions on how to reset your password.</p>', 'buddyboss-theme' ); ?>' );

and the corresponding section of the .po that I have inserted (also with the help of the "Translation suggestions") is the following:

#. Marcello
msgid "<div>Forgot your password?</div><p class=\"message\">Please enter your email address. You will receive an email with instructions on how to reset your password.</p>"
msgstr "<div>Hai dimenticato la password?</div><p class=\"message\">Inserisci il tuo indirizzo email. Riceverai un'e-mail con le istruzioni su come reimpostare la password.</p>"

Unfortunately, the compilation of the .mo after the intervention produces "disastrous" effects on the generated page, as from the 2 pictures

enter image description here

enter image description here

More details

I went to check how the sentence had been translated into other languages ​​and copied the following section from the French .po

msgid ""
"<div>Forgot your password?</div><p class=\"message\">Enter your email "
"address. You will receive a link to create a new password via email.</p>"
msgstr ""
"<div>Vous avez oublié votre mot de passe ?</div><p class=\"message\">Entrez "
"votre adresse e-mail. Vous recevrez un lien pour créer un nouveau mot de "
"passe par courriel.</p>"

Unfortunately in this case the string is not found and the page exits without translation. Should I ask the theme creator to change the code, or is there a way to translate?

1

There are 1 best solutions below

1
On

Translation really can't do such things and it really can't insert different text from what you typed — as your screenshot shows.

Clearly the screenshot does not match the actual content of the translation file (the text differs), so the most likely explanation is that the actually used translation has broken markup in it. Double-check it. Make sure you don't use typographic quotes etc.