Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
After recent updates, String Translation can cause issues where translations do not show up on the front-end, or do show up but seem to revert to the original language after updates to translations using String Translation.

In this case, it was possible to temporarily fix the issue by re-generating the .mo files that WPML uses.

Solution:
This is a known issue that is resolved in upcoming updates. There is a hotfix which requires modifying a file in the String Translation plugin:

File: /wp-content/plugins/wpml-string-translation/classes/MO/File/Generator.php
Change Line 27 - 28 from:

->reduce( [ $this, 'createMOFormatEntities' ], wpml_collect( [] ) )
			->each( [ $mo, 'add_entry' ] );

To:

->reduce( [ $this, 'createMOFormatEntities' ], wpml_collect( [] ) )
            ->filter( function( array $entry ) { return ! empty($entry['singular']); } )
			->each( [ $mo, 'add_entry' ] );

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 12 replies, has 2 voices.

Last updated by Izzi Hassan 10 months, 2 weeks ago.

Assigned support staff: Izzi Hassan.

Author Posts
November 28, 2019 at 6:57 pm #5039237

joshuaA-8

Hi Izzi!

I don't know why, but all string translations we created are not live right now. So, they are not showing up and the whole website is back at the default language English again. Since I did not change anything I don't know where the error is.

Could you please help me here, too?

Best regards!

November 28, 2019 at 7:06 pm #5039261

Izzi Hassan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Joshua,

Creating this new ticket since this might be related to recent updates.

Is there anything you can remember that happened right before this problem?

Best,
Izzi

November 30, 2019 at 6:43 am #5046353

joshuaA-8

Hi Izzi!

No, not really. I updated the website and checked for a module, which does not appear. Posts were created last week, but I guess they do not have influence on this trouble.

Then I was informed that the page is back in English again, but my translations does not change e.g. I added "TEST" to a string in the customizer and translated it to German and Portuguese but it does not show up

December 2, 2019 at 6:20 am #5050733

Izzi Hassan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Joshua,

It looks like this is indeed related to the latest updates. Please share the password for WPML_Support again and I will try and find the problem.

We have come across some other cases of this happening due to permissions issues with the "/wp-content/languages/" folder.

You can see the known issue errata here:
https://wpml.org/errata/hosting-with-read-only-folder-wp-content-languages-issues-with-wpml-string-translation/

I'll look forward to hearing back and thank you for your patience as always!

December 2, 2019 at 6:23 pm #5056177

Izzi Hassan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Joshua,

No problem!

I believe I have solved the immediate problem. We needed to regenerate the .mo files that WPML requires in order to work.

Please check and confirm that the strings are working again.

I could not find the string for "About Us" as it does not appear to be an Admin Text. If you can tell me where you added that button, I can try and help you translate that.

Thank you!

December 2, 2019 at 8:10 pm #5056635

joshuaA-8

Hi Izzi!

I highly appreciate your help here! It's perfect!

Every string, except Knowledgebase (and its subtext) and "About Us"-Button does work now.

Can you help with this final translation, too?

About Us Button is located in BeOnePage_Pro_Child --> Template Parts --> module-contact.php--> line 33

Thanks for your help!

December 3, 2019 at 6:30 am #5057741

Izzi Hassan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Joshua,

When you are adding texts to PHP files in your theme or plugins, you have to mark it for "internationalization". You can do this using PHP's __() and _e() functions. You should always try to provide a text domain when using these functions:
https://developer.wordpress.org/reference/functions/_e/

I have used "amz_custom" as the text domain to fix the "About Us!" text.

Once fixed, I was able to find the About Us string by scanning your child theme for strings using WPML -> Theme and plugins localization. You can find it here:
hidden link

If you can tell me where the Knowledgebase text comes from, we can finally get you back up and running properly!

December 3, 2019 at 8:52 am #5058415

joshuaA-8

Hi Izzi!

Thank you very much for your help 🙂

Unfortunately, we have some other errors right now again. I can only guess what's the cause is. Under String Translation I saw some points as "Needs update", so I updated them and now they are not working again.

I added some images for reference!

I hope you can help here again and then everything works as it should! I am absolutely looking forward to it 🙂

December 3, 2019 at 2:29 pm #5061789

Izzi Hassan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Joshua,

It looks like we might've found a bug after all. Every time you update your String Translation, you have to generate the .mo files again.

This is not normal and I will ask my team to look into this properly. "Knowledgebase" not being translated is also related to the same bug.

I'm not sure if this happened due to the latest updates but we will find out soon!

December 4, 2019 at 2:08 pm #5069615

joshuaA-8

Hi Izzi!

Wonderful! Thanks for your help. Please keep me updated 🙂

December 5, 2019 at 9:37 am #5074881

Izzi Hassan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Joshua,

Looks like the bug has been noticed by other users and fixed in upcoming updates.

I've applied the following fix to your String Translation plugin to solve the issue for now:

File: /wp-content/plugins/wpml-string-translation/classes/MO/File/Generator.php

Changed Line 27 - 28 from:

->reduce( [ $this, 'createMOFormatEntities' ], wpml_collect( [] ) )
			->each( [ $mo, 'add_entry' ] );

To:

->reduce( [ $this, 'createMOFormatEntities' ], wpml_collect( [] ) )
            ->filter( function( array $entry ) { return ! empty($entry['singular']); } )
			->each( [ $mo, 'add_entry' ] );

This also fixed the issue with the Knowledgebase text.

Please confirm that all is well now, or let me know if I've missed anything 🙂

December 5, 2019 at 1:57 pm #5077239

joshuaA-8

My issue is resolved now. Thank you!

December 6, 2019 at 3:46 am #5081183

Izzi Hassan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

I'm happy to hear that Joshua.

Have a great weekend.!