From: Laurent Mazet Date: Sun, 31 May 2020 23:03:23 +0000 (+0200) Subject: add an alert message when all words are correct and fix a bug in the checker function X-Git-Url: https://secure.softndesign.org/git/?a=commitdiff_plain;h=1b960731aca4aec5159240877d57858042180925;p=trivabble.git add an alert message when all words are correct and fix a bug in the checker function --- diff --git a/l10n/po/fr/trivabble.po b/l10n/po/fr/trivabble.po index 39d033e..a837efc 100644 --- a/l10n/po/fr/trivabble.po +++ b/l10n/po/fr/trivabble.po @@ -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}" diff --git a/l10n/pot/trivabble.pot b/l10n/pot/trivabble.pot index 63dc159..85310f6 100644 --- a/l10n/pot/trivabble.pot +++ b/l10n/pot/trivabble.pot @@ -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 "" diff --git a/public/trivabble.js b/public/trivabble.js index 96f0923..fc8a816 100644 --- a/public/trivabble.js +++ b/public/trivabble.js @@ -1548,16 +1548,20 @@ 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)); } }