globalseo
Advanced tools
Comparing version 2.1.92 to 2.1.93
@@ -8,28 +8,36 @@ const extractOptionsFromScript = require("./extractOptionsFromScript.js"); | ||
if (isBrowser()) { | ||
window.translationScriptTag = window.document.currentScript; | ||
window.translationScriptPrevVersion = PREV_SCRIPT_VERSION // called prev version because it will bumped after published to npm | ||
try { | ||
// prevent multiple scripts execution | ||
if (window.firstGlobalseoScriptExecuted) throw new Error("Script already executed"); | ||
window.firstGlobalseoScriptExecuted = true; | ||
const options = extractOptionsFromScript(window) | ||
const {shouldReplaceLinks, langParam, paramsLang, originalLanguage, apiKey, translationMode} = options | ||
// shouldReplaceLinks, | ||
// paramsLang, | ||
// apiKey | ||
window.translationScriptTag = window.document.currentScript; | ||
window.translationScriptPrevVersion = PREV_SCRIPT_VERSION // called prev version because it will bumped after published to npm | ||
function initTranslation() { | ||
// replace links with lang (for SEO purposes) | ||
if (translationMode != 'subdomain' && shouldReplaceLinks && paramsLang && (paramsLang != originalLanguage)) { | ||
replaceLinks(window, {langParam, lang: paramsLang, translationMode: options.translationMode}); | ||
const options = extractOptionsFromScript(window) | ||
const {shouldReplaceLinks, langParam, paramsLang, originalLanguage, apiKey, translationMode} = options | ||
// shouldReplaceLinks, | ||
// paramsLang, | ||
// apiKey | ||
function initTranslation() { | ||
// replace links with lang (for SEO purposes) | ||
if (translationMode != 'subdomain' && shouldReplaceLinks && paramsLang && (paramsLang != originalLanguage)) { | ||
replaceLinks(window, {langParam, lang: paramsLang, translationMode: options.translationMode}); | ||
} | ||
getTranslations(window, apiKey, options) | ||
} | ||
getTranslations(window, apiKey, options) | ||
} | ||
// console.log("window.document.readyState", window.document.readyState) | ||
if (window.document.readyState == 'interactive' || window.document.readyState == 'complete') { | ||
// DOM is already loaded, run the code | ||
initTranslation(); | ||
} else { | ||
// DOM is not loaded yet, wait for it | ||
window.document.addEventListener("DOMContentLoaded", function() { | ||
// console.log("window.document.readyState", window.document.readyState) | ||
if (window.document.readyState == 'interactive' || window.document.readyState == 'complete') { | ||
// DOM is already loaded, run the code | ||
initTranslation(); | ||
}); | ||
} else { | ||
// DOM is not loaded yet, wait for it | ||
window.document.addEventListener("DOMContentLoaded", function() { | ||
initTranslation(); | ||
}); | ||
} | ||
} catch (error) { | ||
console.error("GLOBALSEO Error: ", error); | ||
} | ||
@@ -36,0 +44,0 @@ } |
{ | ||
"name": "globalseo", | ||
"version": "2.1.92", | ||
"version": "2.1.93", | ||
"description": "Translate your React.js or Next.js app with AI", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
559603
3441