Skip Navigation

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

Problem:
After updating the PHP version on the live site, the client encountered a fatal error related to an unknown format specifier in the sprintf function. This error was linked to the LearnDash plugin translations managed by WPML String Translation.

Solution:
We identified that the error was due to incorrect usage of the PHP sprintf function in the translations of the LearnDash plugin. Specifically, many translations were missing the 's' at the end of the placeholders. For example, '%1$' should be '%1$s'. To fix this issue, we recommend:

1. Go to WPML -> String Translation.
2. Filter by the string domain 'learndash' and mark the option 'include translations'.
3. Search for '%2$ ' (with an empty space at the end of the search).

This will display the incorrect translations that are missing the 's' in the placeholder. These translations need correction to conform to the proper usage of sprintf.

If you're experiencing this issue, please also try updating the LearnDash translations under LearnDash LMS > Settings > Translations. If the problem persists, contact LearnDash support for further assistance with correcting the translations containing placeholders.

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

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

Last updated by Mateus Getulio 7 months, 1 week ago.

Assisted by: Mateus Getulio.

Author Posts
May 1, 2024 at 12:30 pm

marcoP-123

we have UPDATE the PHP version in the LIVE site. SO, WE ARE GETTING THIS ERROR - Fatal error: Uncaught ValueError: Unknown format specifier "p"

Can you please check why this error is coming.
if we rename the language folder then it solved.

May 1, 2024 at 1:16 pm
May 1, 2024 at 2:32 pm #15584246

Mateus Getulio
Supporter

Languages: English (English ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello there,

Thank you for your patience while we investigate it.

Upon review, I discovered that the fatal error does not occur when the LearnDash plugins are disabled. This error appears to stem from incorrect usage of the PHP sprintf function. For reference on proper usage, you can visit:

hidden link
hidden link

When using this function, if your argument is a string, it’s crucial to include the parameters in the following format: %(item order)$s (e.g., %1$s, %2$s, %3$s, etc.). This format is correct in the main language, but in WPML -> String Translation, filtering by the 'learndash' domain reveals that many translations are missing the final 's'.

A few examples:

String learndash - placeholders: Lessons, Course, Lesson
Original value(working):

Displays a list of %1$s for a %2$s and tracks %3$s progress

Translation(missing 's' in the placeholders and throwing fatal errors):

Visualizza un elenco di %1$ per un %2$ e tiene traccia dei progressi di %3$.

String learndash - placeholder: Lesson, Lesson
Original value(working):

The video will be visible after the user has completed the %1$s's associated steps. The full video must be watched in order to complete the %2$s.

Italian translation(missing 's' in the placeholders and throwing fatal errors):

Il video sarà visibile dopo che l'utente avrà completato i passaggi associati alla %1$s. Per completare i %2$ è necessario guardare il video completo.

To see a few more examples of this translation issue, please try to:

- Go to WPML -> String Translation
- Filter by the string domain 'learndash' and mark the option 'include translations'
- Search for %2$ (empty space in the end of the search)

You'll see many of those incorrect translations in there missing the 's' chart in the placeholder.

Due to the PHP upgrade, this misuse of sprintf is no longer tolerated and is causing the fatal errors you're experiencing. The translations must be corrected to conform to the proper usage of sprintf to resolve these errors.

I noticed an option to update the LearnDash translations under LearnDash LMS > Settings > Translations. Although I attempted this update, it appears either the translations were not updated, or the new translations still lack the necessary corrections.

Please contact LearnDash support to address this issue and assist with correcting the translations containing placeholders.

Thank you,
Mateus

May 3, 2024 at 9:29 am #15590484

marcoP-123

Please solve the string issue from yourside.

May 3, 2024 at 9:30 am #15590503

marcoP-123

Please sole the string issue as soon as possible.

May 4, 2024 at 6:40 pm #15593699

Mateus Getulio
Supporter

Languages: English (English ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello Marco,

Thank you for reaching out for further assistance.

I understand the urgency of resolving the error messages you are encountering. Upon reviewing the situation in my last reply, it appears that the issue happens due to incorrect translations within the LearnDash plugin strings, specifically in the secondary language settings. This is not inherently a WPML issue.

The sprintf function in PHP, which is used for formatting these strings by LearnDash, requires precise syntax to function correctly. Unfortunately, the translations provided in the secondary language lack the necessary placeholders, leading to the errors you're seeing.

As these strings are part of the LearnDash plugin, the ideal course of action would be to correct the translations either directly or by contacting LearnDash support for a solution. This adjustment should resolve the fatal errors resulting from the recent PHP version update on your site.

Thank you for your understanding and cooperation.

Best regards,

Mateus