Index: gc_lang/fr/modules-js/conj.js ================================================================== --- gc_lang/fr/modules-js/conj.js +++ gc_lang/fr/modules-js/conj.js @@ -14,10 +14,11 @@ _lVtyp: [], _lTags: [], _dPatternConj: {}, _dVerb: {}, + isInit: false, init: function (sJSONData) { try { let _oData = JSON.parse(sJSONData); this._lVtyp = _oData.lVtyp; this._lTags = _oData.lTags; @@ -480,22 +481,24 @@ } } // Initialization -if (typeof(browser) !== 'undefined') { +if (!conj.isInit && typeof(browser) !== 'undefined') { // WebExtension (but not in Worker) conj.init(helpers.loadFile(browser.extension.getURL("grammalecte/fr/conj_data.json"))); -} else if (typeof(require) !== 'undefined') { +} else if (!conj.isInit && typeof(require) !== 'undefined') { // Add-on SDK and Thunderbird conj.init(helpers.loadFile("resource://grammalecte/fr/conj_data.json")); -} else if (typeof(self) !== 'undefined' && typeof(self.port) !== 'undefined' && typeof(self.port.on) !== "undefined") { +} else if ( !conj.isInit && typeof(self) !== 'undefined' && typeof(self.port) !== 'undefined' && typeof(self.port.on) !== "undefined") { // used within Firefox content script (conjugation panel). // can’t load JSON from here, so we do it in ui.js and send it here. self.port.on("provideConjData", function (sJSONData) { conj.init(sJSONData); }); +} else if (conj.isInit){ + console.log("Module conj déjà initialisé"); } else { console.log("Module conj non initialisé"); } Index: gc_lang/fr/modules-js/mfsp.js ================================================================== --- gc_lang/fr/modules-js/mfsp.js +++ gc_lang/fr/modules-js/mfsp.js @@ -15,10 +15,11 @@ // dictionary of words with uncommon plurals (-x, -ux, english, latin and italian plurals) and tags to generate them _dMiscPlur: new Map(), // dictionary of feminine forms and tags to generate masculine forms (singular and plural) _dMasForm: new Map(), + isInit: false, init: function (sJSONData) { try { let _oData = JSON.parse(sJSONData); this._lTagMiscPlur = _oData.lTagMiscPlur; this._lTagMasForm = _oData.lTagMasForm; @@ -98,16 +99,18 @@ } }; // Initialization -if (typeof(browser) !== 'undefined') { +if (!mfsp.isInit && typeof(browser) !== 'undefined') { // WebExtension mfsp.init(helpers.loadFile(browser.extension.getURL("grammalecte/fr/mfsp_data.json"))); -} else if (typeof(require) !== 'undefined') { +} else if (!mfsp.isInit && typeof(require) !== 'undefined') { // Add-on SDK and Thunderbird mfsp.init(helpers.loadFile("resource://grammalecte/fr/mfsp_data.json")); +} else if (mfsp.isInit){ + console.log("Module mfsp déjà initialisé"); } else { console.log("Module mfsp non initialisé"); } Index: gc_lang/fr/modules-js/phonet.js ================================================================== --- gc_lang/fr/modules-js/phonet.js +++ gc_lang/fr/modules-js/phonet.js @@ -8,10 +8,11 @@ var phonet = { _dWord: new Map(), _lSet: [], _dMorph: new Map(), + isInit: false, init: function (sJSONData) { try { let _oData = JSON.parse(sJSONData); this._dWord = helpers.objectToMap(_oData.dWord); this._lSet = _oData.lSet; @@ -79,16 +80,18 @@ } }; // Initialization -if (typeof(browser) !== 'undefined') { +if (!phonet.isInit && typeof(browser) !== 'undefined') { // WebExtension phonet.init(helpers.loadFile(browser.extension.getURL("grammalecte/fr/phonet_data.json"))); -} else if (typeof(require) !== 'undefined') { +} else if (!phonet.isInit && typeof(require) !== 'undefined') { // Add-on SDK and Thunderbird phonet.init(helpers.loadFile("resource://grammalecte/fr/phonet_data.json")); +} else if (phonet.isInit){ + console.log("Module phonet déjà initialisé"); } else { console.log("Module phonet non initialisé"); }