Index: gc_lang/fr/mailext/content/spellchecker.js ================================================================== --- gc_lang/fr/mailext/content/spellchecker.js +++ gc_lang/fr/mailext/content/spellchecker.js @@ -14,20 +14,13 @@ https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/FileUtils.jsm */ "use strict"; -/* -// Loaded in another file -const Cc = Components.classes; -const Ci = Components.interfaces; -const Cu = Components.utils; -const { require } = Cu.import("resource://gre/modules/commonjs/toolkit/require.js", {}); -*/ - -const FileUtils = ChromeUtils.import("resource://gre/modules/FileUtils.jsm").FileUtils; -const AddonManager = ChromeUtils.import("resource://gre/modules/AddonManager.jsm").AddonManager; + +const { FileUtils } = ChromeUtils.import("resource://gre/modules/FileUtils.jsm"); +const { AddonManager } = ChromeUtils.import("resource://gre/modules/AddonManager.jsm"); var oSpellControl = { xSCEngine: null, init: function () { @@ -43,11 +36,10 @@ this.xSCEngine = Cc[sSpellchecker].getService(Ci.mozISpellCheckingEngine); } catch (e) { console.log("Can’t initiate the spellchecker."); console.error(e); - // Cu.reportError(e); } } }, getDictionariesList: function () { this.init(); @@ -57,11 +49,10 @@ this.xSCEngine.getDictionaryList(l, c); return l.value; } catch (e) { console.error(e); - // Cu.reportError(e); return []; } }, setDictionary: function (sLocale) { if (this.getDictionariesList().includes(sLocale)) { @@ -69,11 +60,10 @@ this.xSCEngine.dictionary = sLocale; // en-US, fr, etc. return true; } catch (e) { console.error(e); - // Cu.reportError(e); return false; } } else { console.log("Warning. No dictionary for locale: " + sLocale); console.log("Existing dictionaries: " + this.getDictionariesList().join(" | ")); @@ -85,11 +75,10 @@ try { return this.xSCEngine.check(sWord); } catch (e) { console.error(e); - // Cu.reportError(e); return false; } }, suggest: function (sWord) { try { @@ -98,11 +87,10 @@ return lSugg.value; // lSugg.value is a JavaScript Array of strings } catch (e) { console.error(e); - // Cu.reportError(e); return ['#Erreur.']; } }, addDirectory: function (sFolder) { try { @@ -110,11 +98,10 @@ this.xSCEngine.addDirectory(xNsiFolder); } catch (e) { console.log("Unable to add directory: " + sFolder); console.error(e); - // Cu.reportError(e); } }, removeDirectory: function (sFolder) { // does not work but no exception raised (bug?) try { @@ -122,19 +109,19 @@ this.xSCEngine.removeDirectory(xNsiFolder); } catch (e) { console.log("Unable to remove directory: " + sFolder); console.error(e); - // Cu.reportError(e); } }, setExtensionDictFolder: function (sDictName, bActivate) { try { let that = this; let sPath = "/content/dictionaries/" + sDictName; - AddonManager.getAddonByID("French-GC-TB@grammalecte.net", function (addon) { - let xURI = addon.getResourceURI(sPath); + AddonManager.getAddonByID("French-GC-TB@grammalecte.net") + .then(function (xAddon) { + let xURI = xAddon.getResourceURI(sPath); //console.log(xURI); let sFolder = xURI.filePath; if (sFolder !== undefined) { if (/^\/[A-Z]:\//.test(sFolder)) { // Windows path @@ -150,9 +137,8 @@ }); } catch (e) { console.log("Unable to add extension folder"); console.error(e); - // Cu.reportError(e); } } };