Skip to main content

Quiz result sentence is built from three separate strings, impossible to translate correctly (German)

The quiz result message in the course lesson view is assembled from three separately translated strings. In assets/app.js it looks like this:

... i.isPassed ? " " + e.$t("passed") + " " : " " + e.$t("failed") + " " ...
... e.$t("the quiz.") ...

(the strings are in app/Services/TransStrings.php, around lines 2412 to 2424)

This only works for languages with the same word order as English. In German the result is β€œDu bestanden das Quiz.”, which is grammatically wrong. The correct sentence would be β€œDu hast das Quiz bestanden.”, with the verb at the end. Translators can’t fix this in the .po file, because the pieces are concatenated in the code. Other languages with a different sentence structure will have the same problem.

Suggestion: please use two complete strings instead, for example:

  • You passed the quiz.
  • You failed the quiz.

The colored status styling can still be applied, e.g. by wrapping the sentence or using a placeholder (You %s the quiz.-style strings usually have the same problem, so full sentences are best).

For now I’m working around it with a small gettext filter, but a proper fix in the plugin would help all non-English users.

Thanks!

Mahfuzur Rahman

Thanks for the detailed report and for pointing to the exact strings. I confirmed that the quiz result in the 2.11.0 code is assembled from β€œYou,” β€œpassed” or β€œfailed,” and β€œthe quiz.”, so translators cannot reorder the complete sentence for German. Your suggestion to use separate, complete sentences for the two results is clear and merits developer review. I’ll share your example and proposed change with the product team. Your gettext filter can serve as a workaround on your site while this is reviewed.