Please make sure to update to WPML 4.3.6 and check our list of Known Issues before reporting

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 5 replies, has 2 voices.

Last updated by Raja Mohammed 2 weeks, 6 days ago.

Assigned support staff: Raja Mohammed.

Author Posts
January 29, 2020 at 4:10 am #5381515

technicalS-2

I am trying to import a PO file, and although it works some strings are not importing
I noticed those strings have HTML tags or other non-alphanumeric characters.

January 29, 2020 at 6:23 am #5381907

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello there,

I tried out the import in a test site everything seems to work without any issue, Please refer to the screencast => hidden link

Please share temporary access to your site. Let me check this for you. I have enabled the private reply to securely share the details. To understand this better I would also request your permission to perform a test import of the strings in your live site.

January 29, 2020 at 1:58 pm #5384735

technicalS-2

I did more experimentig and discovered that the PO file is actually being imported correctly (original strings and translated strings). So that part is working. However, all text output from this plugin (using gettext __ function) is NOT translating, if the source text contains the HTML entity / tags. For example:

$o .= $this->table_line(__("Asterisk<sup>®</sup> process awareness","telium-comparison-table"),"F","","H","","F","","H","","F","");

I notice in the string editor that the source and translated string show the registered trademark symbol (R) instead of & reg ; (spaces added to show here) HTML entity. Could it be that WPML is not recognizing my source string because in the strings editor the source and translated strings have the (R) symbol (not the HTML entity)

I'm just guessing, but I confirmed that every string in my PHP file (wrapped in gettext) which contains an HTML entity is NOT translating by WPML when the page is rendered. I'm guessing that I need to prevent WPML from converting HTML entities to unicode characters upon importing the PO file?

This would seem like a huge bug - so I can't believe I'm the first person to encounter this. Can I not use HTML entities in my PHP strings passed to gettext?

January 29, 2020 at 2:31 pm #5385255

technicalS-2

Just adding to above, the code line I pasted actually has the HTML entity (but the browser shows the (R) symbol).

Try to import the .po.es file I sent you, and you will notice that the WPML strings page shows the unicode character (R) displayed, not the & reg ; which is why WPML is not able to match the source string sent by the __() function (which contains the entity).

January 30, 2020 at 6:01 am #5389565

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

After a few other tests i could confirm that the issue is not with html entities they are imported, registered and translated without any issues.

However there is some issue in generating the mo files which is preventing the translation from displaying in frontend, I could confirm this by enabling the option "Look for strings while pages are rendered" In WPML >String translation, Once it is turned on the string imported from the .po file appears as translated in the frontend. The option enables retrieving translation from database and hence it works well this confirms the translation works good but the mo file is not loaded for some reason which needs to be tested.

There are a few other similar cases, I will keep you posted once i have an update.

January 30, 2020 at 6:32 am #5389635

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Applying the below fix as suggested for the issues with translated strings only appears in front end with ""Look for strings while pages are rendered" enabled, Resolves the issue in the test site.

- Goto WPML > String translation,
- Select the strings that is not displayed in the frontend (click on the checkbox)
- At the bottom of the the table hit Delete selected strings
- Goto WPML > Theme and plugin localisation > Theme localisation, Select the theme where the string is added by code and "Scan the them for strings"
- Now goto WPML > String translation, Search for the string and the ES translation manually save and complete.

Since the issue is occurring only in few cases i hope this could help you better. I am still checking this case with the second tier, i will keep you posted once i have something to share with you.

Kind regards
Raja

The topic ‘[Closed] Strings with html entities not imported properly’ is closed to new replies.