Skip to content

Commit f61bc6b

Browse files
committed
fix: wrap hardcoded alert() strings with _() for i18n localization
1 parent 8780709 commit f61bc6b

File tree

5 files changed

+17
-8
lines changed

5 files changed

+17
-8
lines changed

js/activity.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7954,7 +7954,9 @@ class Activity {
79547954
},
79557955
() => {
79567956
alert(
7957-
"Something went wrong reading JSON-encoded project data."
7957+
_(
7958+
"Something went wrong reading JSON-encoded project data."
7959+
)
79587960
);
79597961
}
79607962
);

js/blocks/ProgramBlocks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1472,7 +1472,7 @@ function setupProgramBlocks(activity) {
14721472
win.focus();
14731473
} else {
14741474
// Browser has blocked it.
1475-
alert("Please allow popups for this site");
1475+
alert(_("Please allow popups for this site"));
14761476
}
14771477
}
14781478
}

js/loader.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,8 @@ requirejs(["i18next", "i18nextHttpBackend"], function (i18next, i18nextHttpBacke
321321
console.error(
322322
"FATAL: createjs (EaselJS/TweenJS) not found. Cannot proceed."
323323
);
324-
alert("Failed to load EaselJS. Please refresh the page.");
324+
const t_ = typeof _ === "function" ? _ : s => s;
325+
alert(t_("Failed to load EaselJS. Please refresh the page."));
325326
return;
326327
}
327328

@@ -333,15 +334,18 @@ requirejs(["i18next", "i18nextHttpBackend"], function (i18next, i18nextHttpBacke
333334
},
334335
function (err) {
335336
console.error("Failed to load activity/activity:", err);
336-
alert("Failed to load Music Blocks. Please refresh the page.");
337+
const t_ = typeof _ === "function" ? _ : s => s;
338+
alert(t_("Failed to load Music Blocks. Please refresh the page."));
337339
}
338340
);
339341
}, 100); // Small delay to allow globals to be set
340342
},
341343
function (err) {
342344
console.error("Core bootstrap failed:", err);
345+
const t_ = typeof _ === "function" ? _ : s => s;
343346
alert(
344-
"Failed to initialize Music Blocks core. Please refresh the page.\n\nError: " +
347+
t_("Failed to initialize Music Blocks core. Please refresh the page.") +
348+
"\n\nError: " +
345349
(err.message || err)
346350
);
347351
}

js/utils/synthutils.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ function Synth() {
11001100
if (fileName) {
11011101
download(url, fileName + (platform.FF ? ".wav" : ".ogg"));
11021102
} else {
1103-
alert("Download cancelled.");
1103+
alert(_("Download cancelled."));
11041104
}
11051105
};
11061106
// this.recorder.start();
@@ -1992,7 +1992,10 @@ function Synth() {
19921992
if (Tone.context.state !== "running" && !window.hasShownAudioWarning) {
19931993
window.hasShownAudioWarning = true;
19941994
alert(
1995-
"⚠️ Sound is disabled!\n\nPlease check your browser settings (Site Settings > Sound) to allow audio for Music Blocks."
1995+
"⚠️ " +
1996+
_(
1997+
"Sound is disabled! Please check your browser settings (Site Settings > Sound) to allow audio for Music Blocks."
1998+
)
19961999
);
19972000
}
19982001
}, 2000);

js/widgets/sampler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2247,7 +2247,7 @@ function SampleWidget() {
22472247
this.pitchDetectionAnimationId = requestAnimationFrame(updatePitch);
22482248
} catch (err) {
22492249
console.error(`${err.name}: ${err.message}`);
2250-
alert("Microphone access failed: " + err.message);
2250+
alert(_("Microphone access failed: ") + err.message);
22512251
// Clean up any partially initialized resources
22522252
this.stopPitchDetection();
22532253
}

0 commit comments

Comments
 (0)