Index: gc_lang/fr/dictionnaire/genfrdic.py ================================================================== --- gc_lang/fr/dictionnaire/genfrdic.py +++ gc_lang/fr/dictionnaire/genfrdic.py @@ -840,10 +840,14 @@ if re.search(r"nom|adj", self.po) and re.match(r"(?i)[aâàäáeéèêëiîïíìoôöóòuûüúù]", self.lemma) and re.match("[SFWXAI][.]", self.flags) \ and "pel" not in self.lx: sErr += 'le drapeau derait finir avec *' if not self.flags and self.iz.endswith(("mas", "fem", "epi")): sErr += '[is] incomplet' + if self.flags.startswith(("a", "b", "c", "d")) and not self.lemma.endswith("er"): + sErr += "drapeau pour verbe du 1ᵉʳ groupe sur un lemme non conforme" + if self.flags.startswith("f") and not self.lemma.endswith("ir"): + sErr += "drapeau pour verbe du 2ᵉ groupe sur un lemme non conforme" if sErr: echo(' error - id: ' + self.iD, end = "") echo(' ' + sErr + ' in ' + self.__str__()) def setTagsFrom (self, oEnt): Index: gc_lang/fr/webext/background.js ================================================================== --- gc_lang/fr/webext/background.js +++ gc_lang/fr/webext/background.js @@ -56,13 +56,10 @@ case "getOptions": case "getDefaultOptions": case "resetOptions": // send result to panel storeGCOptions(result); - if (bChrome) { - e.data.result = helpers.mapToObject(e.data.result); - } browser.runtime.sendMessage(e.data); break; case "setOptions": case "setOption": storeGCOptions(result); @@ -73,12 +70,13 @@ default: console.log("[background] Unknown command: " + sActionDone); console.log(e.data); } } - catch (e) { - showError(e); + catch (error) { + showError(error); + console.log(e.data); } }; function initUIOptions (dSavedOptions) { if (!dSavedOptions.hasOwnProperty("ui_options")) { @@ -88,20 +86,26 @@ }}); } } function initGrammarChecker (dSavedOptions) { - let dOptions = (dSavedOptions.hasOwnProperty("gc_options")) ? dSavedOptions.gc_options : null; - if (bChrome) { - // JS crap again. Chrome can’t store Map object. - dOptions = helpers.objectToMap(dOptions); - } - xGCEWorker.postMessage({ - sCommand: "init", - dParam: {sExtensionPath: browser.extension.getURL(""), dOptions: dOptions, sContext: "Firefox"}, - dInfo: {} - }); + try { + let dOptions = (dSavedOptions.hasOwnProperty("gc_options")) ? dSavedOptions.gc_options : null; + if (dOptions !== null && Object.getOwnPropertyNames(dOptions).length == 0) { + console.log("# Error: the saved options was an empty object."); + dOptions = null; + } + xGCEWorker.postMessage({ + sCommand: "init", + dParam: {sExtensionPath: browser.extension.getURL(""), dOptions: dOptions, sContext: "Firefox"}, + dInfo: {} + }); + } + catch (e) { + console.log("initGrammarChecker failed"); + showError(e); + } } function setSpellingDictionary (dSavedDictionary) { if (dSavedDictionary.hasOwnProperty("oExtendedDictionary")) { xGCEWorker.postMessage({ @@ -315,12 +319,11 @@ /* Actions */ function storeGCOptions (dOptions) { - if (bChrome) { - // JS crap again. Chrome can’t store Map object. + if (dOptions instanceof Map) { dOptions = helpers.mapToObject(dOptions); } browser.storage.local.set({"gc_options": dOptions}); } Index: gc_lang/fr/webext/content_scripts/init.js ================================================================== --- gc_lang/fr/webext/content_scripts/init.js +++ gc_lang/fr/webext/content_scripts/init.js @@ -238,11 +238,11 @@ } else { oGrammalecte.oLxgPanel.stopWaitIcon(); } break; case "getSpellSuggestions": - oGrammalecte.oGCPanel.oTooltip.setSpellSuggestionsFor(result.sWord, result.aSugg, dInfo.sErrorId); + oGrammalecte.oGCPanel.oTooltip.setSpellSuggestionsFor(result.sWord, result.aSugg, result.iSuggBlock, dInfo.sErrorId); break; /* Commands received from the context menu (Context menu are initialized in background) */ Index: gc_lang/fr/webext/content_scripts/panel_gc.css ================================================================== --- gc_lang/fr/webext/content_scripts/panel_gc.css +++ gc_lang/fr/webext/content_scripts/panel_gc.css @@ -111,13 +111,14 @@ font-size: 11px; font-style: normal; text-align: center; } #grammalecte_tooltip_message { + margin: 0 0 5px 0; font-family: Tahoma, "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", sans-serif; font-size: 15px; - margin: 0 0 5px 0; + color: hsl(210, 50%, 96%); } #grammalecte_tooltip_ignore { display: inline-block; padding: 1px 5px; background-color: hsl(30, 30%, 40%); @@ -150,10 +151,21 @@ color: hsla(0, 0%, 100%, 1); text-shadow: 0 0 3px hsl(210, 30%, 60%); } #grammalecte_tooltip_sugg_title { padding: 0 10px; + background-color: hsl(210, 10%, 90%); + color: hsl(210, 50%, 30%); + font-family: Tahoma, "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", sans-serif; + font-size: 10px; + font-weight: bold; +} +.grammalecte_tooltip_other_sugg_title { + margin: 5px 0; + padding: 0px 10px; + line-height: normal; + border-radius: 2px; background-color: hsl(210, 10%, 90%); color: hsl(210, 50%, 30%); font-family: Tahoma, "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", sans-serif; font-size: 10px; font-weight: bold; Index: gc_lang/fr/webext/content_scripts/panel_gc.js ================================================================== --- gc_lang/fr/webext/content_scripts/panel_gc.js +++ gc_lang/fr/webext/content_scripts/panel_gc.js @@ -392,19 +392,26 @@ xNodeSugg.dataset.error_id = sErrorId; xNodeSugg.textContent = sSugg; return xNodeSugg; } - setSpellSuggestionsFor (sWord, aSugg, sErrorId) { + setSpellSuggestionsFor (sWord, aSugg, iSuggBlock, sErrorId) { // spell checking suggestions try { if (sErrorId === this.sErrorId) { let xSuggBlock = document.getElementById("grammalecte_tooltip_sugg_block"); - xSuggBlock.textContent = ""; + if (iSuggBlock == 0) { + xSuggBlock.textContent = ""; + } if (!aSugg || aSugg.length == 0) { - xSuggBlock.appendChild(document.createTextNode("Aucune.")); + if (iSuggBlock == 0) { + xSuggBlock.appendChild(document.createTextNode("Aucune.")); + } } else { + if (iSuggBlock > 0) { + xSuggBlock.appendChild(oGrammalecte.createNode("div", {className: "grammalecte_tooltip_other_sugg_title", textContent: "AUTRES SUGGESTIONS :"})); + } let iSugg = 0; for (let sSugg of aSugg) { xSuggBlock.appendChild(this._createSuggestion(sErrorId, iSugg, sSugg)); xSuggBlock.appendChild(document.createTextNode(" ")); iSugg += 1; @@ -411,10 +418,11 @@ } } } } catch (e) { + let xSuggBlock = document.getElementById("grammalecte_tooltip_sugg_block"); xSuggBlock.appendChild(document.createTextNode("# Oups. Le mécanisme de suggestion orthographique a rencontré un bug… (Ce module est encore en phase β.)")); showError(e); } } } Index: gc_lang/fr/webext/gce_worker.js ================================================================== --- gc_lang/fr/webext/gce_worker.js +++ gc_lang/fr/webext/gce_worker.js @@ -166,25 +166,26 @@ //console.log("[Worker] Modules have been initialized…"); gc_engine.load(sContext, sExtensionPath+"grammalecte/graphspell/_dictionaries"); oSpellChecker = gc_engine.getSpellChecker(); oTest = new TestGrammarChecking(gc_engine, sExtensionPath+"/grammalecte/fr/tests_data.json"); oTokenizer = new Tokenizer("fr"); - oLocution = helpers.loadFile(sExtensionPath + "/grammalecte/fr/locutions_data.json"); - oLxg = new Lexicographe(oSpellChecker, oTokenizer, oLocution); if (dOptions !== null) { - console.log(dOptions); + if (!(dOptions instanceof Map)) { + dOptions = helpers.objectToMap(dOptions); + } gc_engine.setOptions(dOptions); } //tests(); bInitDone = true; } else { console.log("[Worker] Already initialized…") } // we always retrieve options from the gc_engine, for setOptions filters obsolete options - postMessage(createResponse("init", gc_engine.getOptions(), dInfo, true)); + dOptions = helpers.mapToObject(gc_engine.getOptions()); + postMessage(createResponse("init", dOptions, dInfo, true)); } catch (e) { helpers.logerror(e); postMessage(createResponse("init", createErrorResult(e, "init failed"), dInfo, true, true)); } @@ -218,33 +219,41 @@ let aSpellErr = oSpellChecker.parseParagraph(sParagraph); postMessage(createResponse("parseAndSpellcheck1", {sParagraph: sParagraph, aGrammErr: aGrammErr, aSpellErr: aSpellErr}, dInfo, true)); } function getOptions (dInfo={}) { - postMessage(createResponse("getOptions", gc_engine.getOptions(), dInfo, true)); + let dOptions = helpers.mapToObject(gc_engine.getOptions()); + postMessage(createResponse("getOptions", dOptions, dInfo, true)); } function getDefaultOptions (dInfo={}) { - postMessage(createResponse("getDefaultOptions", gc_engine.getDefaultOptions(), dInfo, true)); + let dOptions = helpers.mapToObject(gc_engine.getDefaultOptions()); + postMessage(createResponse("getDefaultOptions", dOptions, dInfo, true)); } function setOptions (dOptions, dInfo={}) { + if (!(dOptions instanceof Map)) { + dOptions = helpers.objectToMap(dOptions); + } gc_engine.setOptions(dOptions); - postMessage(createResponse("setOptions", gc_engine.getOptions(), dInfo, true)); + dOptions = helpers.mapToObject(gc_engine.getOptions()); + postMessage(createResponse("setOptions", dOptions, dInfo, true)); } function setOption (sOptName, bValue, dInfo={}) { console.log(sOptName+": "+bValue); if (sOptName) { gc_engine.setOption(sOptName, bValue); - postMessage(createResponse("setOption", gc_engine.getOptions(), dInfo, true)); + let dOptions = helpers.mapToObject(gc_engine.getOptions()); + postMessage(createResponse("setOption", dOptions, dInfo, true)); } } function resetOptions (dInfo={}) { gc_engine.resetOptions(); - postMessage(createResponse("resetOptions", gc_engine.getOptions(), dInfo, true)); + let dOptions = helpers.mapToObject(gc_engine.getOptions()); + postMessage(createResponse("resetOptions", dOptions, dInfo, true)); } function tests () { console.log(conj.getConj("devenir", ":E", ":2s")); console.log(mfsp.getMasForm("emmerdeuse", true)); @@ -323,13 +332,13 @@ function getSpellSuggestions (sWord, dInfo) { if (!oSpellChecker) { postMessage(createResponse("getSpellSuggestions", "# Error. SpellChecker not loaded.", dInfo, true)); return; } - let i = 1; + let i = 0; for (let aSugg of oSpellChecker.suggest(sWord)) { - postMessage(createResponse("getSpellSuggestions", {sWord: sWord, aSugg: aSugg, iSugg: i}, dInfo, true)); + postMessage(createResponse("getSpellSuggestions", {sWord: sWord, aSugg: aSugg, iSuggBlock: i}, dInfo, true)); i += 1; } } Index: gc_lang/fr/webext/manifest.json ================================================================== --- gc_lang/fr/webext/manifest.json +++ gc_lang/fr/webext/manifest.json @@ -1,10 +1,10 @@ { "manifest_version": 2, "name": "Grammalecte [fr]", "short_name": "Grammalecte [fr]", - "version": "0.6.2", + "version": "0.6.2.1", "applications": { "gecko": { "id": "French-GC@grammalecte.net", "strict_min_version": "56.0" Index: gc_lang/fr/webext/panel/main.html ================================================================== --- gc_lang/fr/webext/panel/main.html +++ gc_lang/fr/webext/panel/main.html @@ -26,14 +26,14 @@
Grammaire
Zone de test