[Feature Request] I would like to submit a feature suggestion
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.
Heute stehen keine Supporter zur Arbeit im German-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.
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.
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)
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:
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.
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.
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.