Skip to content

Commit aece492

Browse files
Modify hint delay to make it easier to change
Signed-off-by: David A. Wheeler <[email protected]>
1 parent c9e2cf3 commit aece492

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

docs/labs/checker.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const resources = {
4747
reset_title: 'Reset initial state (throwing away current attempt).',
4848
to_be_completed: 'to be completed',
4949
try_harder_give_up: "Try harder! Don't give up so soon. Current time spent since start or last hint (in seconds): {0}",
50-
try_harder_hint: "Try harder! Don't ask for a hint so soon, wait at least 15 seconds.",
50+
try_harder_hint: "Try harder! Don't ask for a hint so soon, wait at least {0} seconds.",
5151
},
5252
},
5353
ja: {
@@ -65,7 +65,7 @@ const resources = {
6565
reset_title: '初期状態をリセットします (現在の試行を破棄します)。',
6666
to_be_completed: '完成する',
6767
try_harder_give_up: 'もっと頑張れ!そんなにすぐに諦めないでください。開始または最後のヒントから経過した現在の時間 (秒単位): {0}',
68-
try_harder_hint: "もっと頑張れ!すぐにヒントを求めず、少なくとも 15 秒待ちます。",
68+
try_harder_hint: "もっと頑張れ!すぐにヒントを求めず、少なくとも {0} 秒待ちます。",
6969
},
7070
},
7171
fr: {
@@ -84,7 +84,7 @@ const resources = {
8484
to_be_completed: 'à compléter',
8585
try_harder_give_up: "Essayez plus fort ! N'abandonnez pas si tôt. Temps actuel passé (en secondes) : {0}",
8686
try_harder_give_up: "Essayez plus fort ! N'abandonnez pas si tôt. Temps actuel passé depuis le début ou le dernier indice (en secondes) : {0}",
87-
try_harder_hint: "Essayez plus fort ! Ne demandez pas d'indice si tôt, attendez au moins 15 secondes.",
87+
try_harder_hint: "Essayez plus fort ! Ne demandez pas d'indice si tôt, attendez au moins {0} secondes.",
8888
},
8989
},
9090
};
@@ -565,9 +565,17 @@ const GIVE_UP_DELAY_TIME = 60;
565565

566566
// "Hint" only shows hint after this many seconds have elapsed
567567
// since a clue (lab start or a hint given).
568-
// Adjust text try_harder_hint if you change this. The text includes the
569-
// number because pluralization rules vary depending on the natural language,
570-
// and we want to tell the user the delay for hints.
568+
// WARNING: If you change this value, you *may* need to adjust some of
569+
// the translated texts for try_harder_hint.
570+
// Pluralization rules vary depending on the natural language,
571+
// yet we want to tell the user the exact delay value for hints.
572+
// English, French, German, and some others have two forms, "one" and "other"
573+
// (aka "singular" and "plural" forms of words).
574+
// For Chinese and Japanese it doesn't matter (there's no difference).
575+
// In those cases, you only need to change translations if you change between
576+
// not-1 to 1, which is unlikely. However,
577+
// for some languages like Arabic, Hebrew, and Russian it's more complicated.
578+
// See: https://localizely.com/language-plural-rules/
571579
const HINT_DELAY_TIME = 15;
572580

573581
/** return time (in seconds) since start and/or last hint */
@@ -594,8 +602,7 @@ function maybeShowHint(e) {
594602
// people can re-see a previously-seen hint as long as they
595603
// have not changed anything since seeing the hint.
596604
if (changedInputSinceHint && (elapsedTime < HINT_DELAY_TIME)) {
597-
// Provide elapsed time (in seconds) in case we want to use it.
598-
alert(t('try_harder_hint').format(elapsedTime.toString()));
605+
alert(t('try_harder_hint').format(HINT_DELAY_TIME.toString()));
599606
} else {
600607
lastHintTime = Date.now(); // Set new delay time start
601608
changedInputSinceHint = false; // Allow redisplay of hint

0 commit comments

Comments
 (0)