add an alert message when all words are correct and fix a bug in the checker function
authorLaurent Mazet <mazet@softndesign.org>
Sun, 31 May 2020 23:03:23 +0000 (01:03 +0200)
committerLaurent Mazet <mazet@softndesign.org>
Tue, 9 Jun 2020 20:24:55 +0000 (22:24 +0200)
l10n/po/fr/trivabble.po
l10n/pot/trivabble.pot
public/trivabble.js

index 39d033e5f2166751da1842d9da27e7effcf4b521..a837efc509cf073ac663710e31243e3986d43787 100644 (file)
@@ -169,5 +169,8 @@ msgstr "{0} a changĂ© la langue du plateau en {1}"
 msgid  "Check spelling for new words"
 msgstr "VĂ©rifier l'orthographe des mots nouveaux"
 
-msgid  "Incorrect speeling for {0}"
-msgstr "Orthographe incorrecte pour {0}"
+msgid  "Incorrect speeling for {0} from {1}"
+msgstr "Orthographe incorrecte pour {0} parmi {1}"
+
+msgid  "All words are correct: {0}"
+msgstr "Tous les mots sont corrects : {0}"
index 63dc159dc8b7c3c2e9d91222aa17fa4fa76cb59c..85310f6c4bcb61a50f87ea83ec20c283288e56ee 100644 (file)
@@ -175,5 +175,8 @@ msgstr ""
 msgid  "Check spelling for new words"
 msgstr ""
 
-msgid  "Incorrect speeling for {0}"
+msgid  "Incorrect speeling for {0} from {1}"
+msgstr ""
+
+msgid  "All words are correct: {0}"
 msgstr ""
index 96f09234b7f4b4247ff63a8d64947bcfccfbf206..fc8a816377cab3898241ecb28e3dd5dc99d35999 100644 (file)
         let words = searchNewWords();
 
         /* Check if words are in dictionnary */
-        for (const k of Object.keys(words)) {
-            if (dictionnary.includes(words[k])) {
-                delete words[k];
+        let badWords = words.slice();
+        for (const k of Object.keys(badWords)) {
+            if (dictionnary.includes(badWords[k])) {
+                delete badWords[k];
             }
         }
-        words = words.join(" ");
+        words = words.join(" ").replace(/^ */, "").replace(/ *$/, "");
+        badWords = badWords.join(" ").replace(/^ */, "").replace(/ *$/, "");
 
         /* Advice on erroneous spelling */
-        if (words.length > 0) {
-            myAlert(format(_("Incorrect speeling for {0}"), words));
+        if (badWords.length > 0) {
+            myAlert(format(_("Incorrect speeling for {0} from {1}"), badWords, words));
+        } else if (words.length > 0) {
+            myAlert(format(_("All words are correct: {0}"), words));
         }
     }