From 1b960731aca4aec5159240877d57858042180925 Mon Sep 17 00:00:00 2001 From: Laurent Mazet Date: Mon, 1 Jun 2020 01:03:23 +0200 Subject: [PATCH] add an alert message when all words are correct and fix a bug in the checker function --- l10n/po/fr/trivabble.po | 7 +++++-- l10n/pot/trivabble.pot | 5 ++++- public/trivabble.js | 16 ++++++++++------ 3 files changed, 19 insertions(+), 9 deletions(-) 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)); } } -- 2.30.2