Skip to content

fix: wrap hardcoded alert() strings with _() for i18n localization#6005

Open
vanshika2720 wants to merge 2 commits intosugarlabs:masterfrom
vanshika2720:fix/localize-hardcoded-alert-strings
Open

fix: wrap hardcoded alert() strings with _() for i18n localization#6005
vanshika2720 wants to merge 2 commits intosugarlabs:masterfrom
vanshika2720:fix/localize-hardcoded-alert-strings

Conversation

@vanshika2720
Copy link
Contributor

@vanshika2720 vanshika2720 commented Mar 1, 2026

fix: localize hardcoded alert() strings for full i18n coverage

What

Wraps all hardcoded English alert() strings with _() so they participate in Music Blocks’ i18n system and are translatable for non-English users.

This completes a targeted audit of user-facing alert dialogs across the JavaScript codebase.


Files Changed (5)

  • js/blocks/ProgramBlocks.js
  • js/activity.js
  • js/utils/synthutils.js
  • js/widgets/sampler.js
  • js/loader.js

Notable Implementation Detail

loader.js Bootstrap Guard

loader.js executes during early RequireJS bootstrap, before _() is guaranteed to exist.

Each alert site uses an inline safety guard:

const t_ = typeof _ === "function" ? _ : s => s;
alert(t_("..."));

This is intentional because:

  • These alerts are inside separate RequireJS callbacks.
  • They fire only during bootstrap failure paths.
  • Each site is independently safe and self-contained.
  • Avoids restructuring early initialization code in a surgical fix branch.

There are no functional behavior changes — only localization support added.

Intentionally Not Changed

  • js/SaveInterface.js — alert strings appear inside dynamically generated HTML source text, not runtime UI alerts.
  • js/blocks/ActionBlocks.js — alert(xmlHttp.responseText) is fully dynamic server content (no static English string to localize).
  • Alerts already wrapped in _() were left untouched.

Scope

  • No refactors
  • No structural changes
  • No behavior changes
  • Localization-only fix
    This keeps the PR small, reviewable, low-risk, and focused strictly on improving i18n coverage.
  • Bug Fix

@github-actions
Copy link
Contributor

github-actions bot commented Mar 1, 2026

✅ All Jest tests passed! This PR is ready to merge.

@vanshika2720
Copy link
Contributor Author

@walterbender

@Ashutoshx7
Copy link
Contributor

@vanshika2720 tried it locally it seems okay to me !
great works btw

@walterbender
Copy link
Member

Looks good but there seem to be unrelated changes in sampler.js. Please remove those changes.

@vanshika2720 vanshika2720 force-pushed the fix/localize-hardcoded-alert-strings branch from f3caad7 to f07606c Compare March 8, 2026 21:42
@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2026

❌ Some Jest tests failed. Please check the logs and fix the issues before merging.

Failed Tests:

GraphicsBlocks.test.js

@vanshika2720 vanshika2720 force-pushed the fix/localize-hardcoded-alert-strings branch from f07606c to 24fbd97 Compare March 8, 2026 21:45
@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2026

❌ Some Jest tests failed. Please check the logs and fix the issues before merging.

Failed Tests:

GraphicsBlocks.test.js

@vanshika2720 vanshika2720 force-pushed the fix/localize-hardcoded-alert-strings branch from 24fbd97 to f61bc6b Compare March 8, 2026 21:56
@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2026

❌ Some Jest tests failed. Please check the logs and fix the issues before merging.

Failed Tests:

GraphicsBlocks.test.js

@vanshika2720 vanshika2720 force-pushed the fix/localize-hardcoded-alert-strings branch from 939a4a1 to 9a9f85e Compare March 8, 2026 22:42
@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2026

✅ All Jest tests passed! This PR is ready to merge.

1 similar comment
@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2026

✅ All Jest tests passed! This PR is ready to merge.

@vanshika2720 vanshika2720 force-pushed the fix/localize-hardcoded-alert-strings branch from 9a9f85e to 8f71279 Compare March 8, 2026 23:19
@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2026

✅ All Jest tests passed! This PR is ready to merge.

@github-actions github-actions bot added the bug fix Fixes a bug or incorrect behavior label Mar 8, 2026
@vanshika2720 vanshika2720 force-pushed the fix/localize-hardcoded-alert-strings branch from 8f71279 to 11e898c Compare March 8, 2026 23:28
@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2026

❌ Some Jest tests failed. Please check the logs and fix the issues before merging.

Failed Tests:

GraphicsBlocks.test.js

@Ashutoshx7
Copy link
Contributor

@vanshika2720 there is still lint faling in sampler.js
take a look

@vanshika2720
Copy link
Contributor Author

@Ashutoshx7 YES i am working on it.

@vanshika2720 vanshika2720 force-pushed the fix/localize-hardcoded-alert-strings branch from 11e898c to c6a06de Compare March 9, 2026 18:15
@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

✅ All Jest tests passed! This PR is ready to merge.

@vanshika2720
Copy link
Contributor Author

Looks good but there seem to be unrelated changes in sampler.js. Please remove those changes.

@walterbender Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug fix Fixes a bug or incorrect behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants