Navigation überspringen

Dieses Thema ist gelöst. Hier finden Sie eine Beschreibung des Problems und der Lösung.

Problem:
The client reported an issue where incorrect translations of strings with placeholders (like those used in

sprintf

or

printf

functions) caused errors on a PHP 8.x environment. This resulted in an inability to place orders in the shop due to a missing placeholder in the translated string.
Solution:
We acknowledged the client's feature suggestion for WPML to scan strings in the string translation table for missing placeholders. However, after reviewing the suggestion and monitoring for similar issues, we have decided not to implement this feature. We have not observed other clients experiencing this problem, and our development team has chosen not to prioritize this as a future feature.

Please note that this solution might be irrelevant if it's outdated or not applicable to your case. If you're still encountering issues, we highly recommend checking the related known issues, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the problem persists, please open a new support ticket with us.

Dies ist das technische Support-Forum für WPML – das mehrsprachige WordPress-Plugin.

Mitlesen können alle, doch nur WPML-Kunden können hier Fragen veröffentlichen. Das WPML-Team antwortet im Forum an 6 Tagen pro Woche, 22 Stunden am Tag.

Schlagwörter: 

Dieses Thema enthält 8 Antworten, hat 3 Stimmen.

Zuletzt aktualisiert von Marcel Vor 9 Monaten, 3 Wochen.

Assistiert von: Marcel.

Verfasser Beiträge
September 26, 2023 unter 8:38 am #14464541

cons-2

I would like to submit a feature suggestion.

We recently updated from PHP 7.4 to PHP 8.x. There are hard errors in PHP 8.x, for example when not all placeholders in functions like sprintf or printf can be assigned correctly.

In our case, an incorrectly translated string meant that it was no longer possible to order in the shop.

Example:
- Original: Tom is %d years old and his last name is %s.
- translsation EN: Tom is %d years old and his last name is %s.
- translation FR: Tom a %d ans et son nom de famille est s.

FR translation will not work because the second placeholder is not translated correctly and the page will have an error.

My suggestion: WPML should scan strings in the string translation table and display a list of strings that do not contain all placeholders and original text.
This can reduce translation errors and expensive site downtime.

September 26, 2023 unter 9:01 am #14464977

cons-2

Here is a short blog article about the problem: versteckter Link

September 26, 2023 unter 9:02 am #14464979

Bruno Kos
Supporter

Sprachen: Englisch (English ) Deutsch (Deutsch ) Französisch (Français )

Zeitzone: Europe/Zagreb (GMT+01:00)

In order to submit a feature request to our team, I need to have a clear idea on the issue.

Can you record a video using a tool such as versteckter Link to illustrate the issue both in the frontend and backend during the translation?

This will ensure we are 100% on the scenario where this happens.

September 26, 2023 unter 9:34 am #14465371

cons-2

I have described errors.
Post with a concrete example is linked.
Developers should immediately understand what this is about.

Here's how you can reproduce the error:
- open string translation
- search for a string with wildcards. e.g. %s
- Translate the string correctly and replace the placeholder in the translation with something else, remove it, whatever. (e.g. EN: "click %shere%s" => DE: "hier %s klicken" )
- save string translation
- go to page where the mistranslated string is displayed. Error should occur.

If the placeholder is not translated correctly/completely, then there is a fatal error in the function that calls the string with sprintf/prinf.

- It may be that a page is not displayed.
- It may be that an order in WooCommerce cannot be placed.
- A cronjob task may fail.
Many errors are possible, depending on the context that calls the string with sprintf/printf.

Our problem was that you couldn't put products in your shopping cart in the incorrectly translated language FR.
(ajax action failed)

September 26, 2023 unter 9:39 am #14465461

cons-2

Important: Use PHP 8.x to reduce the error.
The error does not occur with PHP 7.x.

September 27, 2023 unter 9:07 am #14471885

Marcel
Supporter

Sprachen: Englisch (English ) Deutsch (Deutsch )

Zeitzone: Europe/Madrid (GMT+01:00)

Hi,

thanks for your report.

When you get "Uncaught ValueError: Missing format specifier at end of", it indicates you the line where the call comes from, so you can get the exact string that is causing it from the line of code calling it. If you look at the stack trace, it will also show you the actual string, for example:

#0 wp-content\plugins\woocommerce\includes\class-wc-post-types.php(234): sprintf('Alle %', 'Marke'),

This way, you see that the "s" is missing. I will share it with our devs and keep you updated.

Best Regards
Marcel

September 27, 2023 unter 10:44 am #14472989

Marcel
Supporter

Sprachen: Englisch (English ) Deutsch (Deutsch )

Zeitzone: Europe/Madrid (GMT+01:00)

Hi,

our developers decided not to implement this feature, as the ability to break the translation is possible even on WordPress without WPML. The same error would appear if you pass the wrong translation in the .mo file itself without WPML.

Thanks again for providing your feedback on this matter.

Best Regards
Marcel

September 27, 2023 unter 2:04 pm #14474817

cons-2

Thanks for the feedback.
Of course, the error can occur when we manually create mo-files for third party plugins.
(Although I've never done this.)

What worries me about the current situation is that with deepL integration we automatically translate a lot of plugin texts and admin texts via string translation.

Rarely, but now and then, there have been placeholder errors in the past that we were fortunate to notice.
After the PHP 8 upgrade, how should we check thousands of strings that deepL has translated for us in the past?
Future translations with placeholders must also be correct so that there are no fatal errors due to a few incorrectly translated texts.

If we add a new language in the future, we would have to test every possible page and function on the website to find and eliminate any errors.
Otherwise, users of the new language may not be able to access certain areas or functions.
That would annoy users and cost us money.

In the ideal world, this is possible and we check the entire shop from A to Z.
But at some point a website is so large that this can no longer be done efficiently manually.
Here WPML could help to increase the security of the content translated with string translation and provide a great service.

It would be enough to have an admin page that shows a warning if content was found in the string translation table where not all placeholders from the original language were included in the translation.

Please give me a final signal of what you think about this.

Februar 15, 2024 unter 10:28 am #15306324

Marcel
Supporter

Sprachen: Englisch (English ) Deutsch (Deutsch )

Zeitzone: Europe/Madrid (GMT+01:00)

Hi there!

Thanks again for bringing this to our attention. We've been keeping an eye on the issue since you reported it, and it seems like no other clients have experienced this problem. We really appreciate you sharing your feedback with us. After careful consideration, our development team has decided not to move forward with incorporating this into a future feature release.

All the best,
Marcel