Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: error messages aren't displayed as translated strings #2160

Merged
merged 4 commits into from
Jan 27, 2025

Conversation

handeyeco
Copy link
Contributor

@handeyeco handeyeco commented Jan 27, 2025

Summary:

Proposing a bug fix for error messages not showing up as translated: https://khanacademy.slack.com/archives/C06FULVQLSV/p1738014199191129?thread_ts=1738012970.693379&cid=C06FULVQLSV

What I thought we were doing: Originally I thought strings were getting replaced during the translation process (I don't know why I thought that). So we were mapping error codes to error strings directly off of strings.

What we were actually doing: strings isn't actually changed, it's used to make a new object that has all of the translated strings in it. So we were pulling the English strings off of the base object that was used to create a separate translated object.

What this PR does: instead of pulling from strings, we instead pass the translated strings into mapErrorToString. Then we map an error code to a key that we use to access the translated message from the passed in object.

Test plan:

  • Go into a non-English language (like Portuguese)
  • Go to a Radio widget that requires multiple selections
  • Select one right answer, but not all right answers
  • Submit question
  • There should be an error message displayed
    • broken: that message will be English
    • patched: that message will be Portuguese

@handeyeco handeyeco self-assigned this Jan 27, 2025
Copy link
Contributor

github-actions bot commented Jan 27, 2025

npm Snapshot: Published

Good news!! We've packaged up the latest commit from this PR (98435b3) and published it to npm. You
can install it using the tag PR2160.

Example:

yarn add @khanacademy/perseus@PR2160

If you are working in Khan Academy's webapp, you can run:

./dev/tools/bump_perseus_version.sh -t PR2160

@handeyeco handeyeco changed the title [translated-error-bugs] possible fix Bugfix: error messages aren't displayed as translated strings Jan 27, 2025
Copy link
Member

@jeresig jeresig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok to me, thank you!

Copy link
Contributor

github-actions bot commented Jan 27, 2025

Size Change: -3.57 kB (-0.24%)

Total Size: 1.48 MB

Filename Size Change
packages/perseus/dist/es/index.js 381 kB -3.64 kB (-0.95%)
packages/perseus/dist/es/strings.js 5.82 kB +71 B (+1.24%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 39 kB
packages/keypad-context/dist/es/index.js 760 B
packages/kmath/dist/es/index.js 86.8 kB
packages/math-input/dist/es/index.js 77.6 kB
packages/math-input/dist/es/strings.js 1.79 kB
packages/perseus-core/dist/es/index.js 43.1 kB
packages/perseus-editor/dist/es/index.js 688 kB
packages/perseus-linter/dist/es/index.js 22.2 kB
packages/perseus-score/dist/es/index.js 113 kB
packages/pure-markdown/dist/es/index.js 3.66 kB
packages/simple-markdown/dist/es/index.js 12.5 kB

compressed-size-action

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay for future proofing!

@handeyeco handeyeco merged commit 26de8f4 into main Jan 27, 2025
8 checks passed
@handeyeco handeyeco deleted the translated-error-bugs branch January 27, 2025 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants