kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

Perseus strings with a context and placeholders are text, not functions, in 0.20

Open rtibblesbot opened this issue 1 week ago • 0 comments

❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.

Target branch: release-v0.20.x

Observed behavior

  • wrapPerseusMessages(perseusTranslator).srLinearGraphPoints is a string. Perseus 78.2.0 calls it as strings.srLinearGraphPoints({ point1X, point1Y, point2X, point2Y }).
  • The same holds for all 74 PerseusInternalMessages entries that have both a context and a placeholder, such as srPointAtCoordinates, srCircleShape, srPolygonSideLength and molecularDrawing.
  • _getTranslatedStringOrFunction tests /{/ against the default message. For a { message, context } entry that is an object, so the test never matches.
  • Placeholder messages without a context, such as hintPos, resolve to functions.

Expected behavior

Each of those 74 entries resolves to a function of its arguments, as on develop since 0b4ae602a0.

User-facing consequences

Perseus 78.2.0 calls strings.srLinearGraphPoints(…) in describeLinearGraph while it renders a linear interactive graph. Calling a string throws a TypeError, which Perseus shows as its "Rendering Error!" icon in place of the widget, as in #16054.

Steps to reproduce

  1. Check out release-v0.20.x at e3b074b70f.
  2. In a Jest spec under kolibri/plugins/perseus_viewer/frontend/__tests__/, import wrapPerseusMessages from ../translationUtils and perseusTranslator from ../translator.
  3. Evaluate typeof wrapPerseusMessages(perseusTranslator).srLinearGraphPoints. It is 'string'; for hintPos it is 'function'.

Context

  • Kolibri release-v0.20.x at e3b074b70f
  • @khanacademy/perseus 78.2.0

Acceptance Criteria

  • [ ] On release-v0.20.x, every PerseusInternalMessages message with a placeholder resolves to a function through wrapPerseusMessages, with or without a context.
  • [ ] A Jest test calls a placeholder message that has a context with its arguments and gets the formatted text.

AI usage

Claude Code found this while planning #16054 and drafted the issue.

rtibblesbot avatar Nov 26 '26 04:11 rtibblesbot