From aa7092f0c58b6990467d4e14c2a72bea1e1b8b2c Mon Sep 17 00:00:00 2001 From: jemikanegara Date: Tue, 29 Oct 2024 23:15:42 +0800 Subject: [PATCH] replace path mode into subdirectory --- README.md | 2 +- extractOptionsFromScript.js | 2 +- replaceLinks.js | 2 +- utils/selector/createLanguageSelect.js | 2 +- utils/translation/isStillSameLang.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 225a4a6..7a6d5c9 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Place the following script inside your tag - **data-exclude-ids**: List IDs to exclude from translation, separated by commas (e.g., `user-comment, code-snippet` will prevent translation of elements with ID `user-comment` and `code-snippet`). #### Server Side Rendering Configuration: -- **data-translation-mode**: Modify the translated pages logic. Set to `subdomain` to point to subdomains (for example: de.domain.com), or `path` to point to paths (for example: domain.com/de). *DONT USE* if you are not using SSR (SSR only available in higher plans). +- **data-translation-mode**: Modify the translated pages logic. Set to `subdomain` to point to subdomains (for example: de.domain.com), or `subdirectory` to point to paths (for example: domain.com/de). *DONT USE* if you are not using SSR (SSR only available in higher plans). View more options [here](#advanced-configuration). diff --git a/extractOptionsFromScript.js b/extractOptionsFromScript.js index 7c3fa04..f97f3bc 100644 --- a/extractOptionsFromScript.js +++ b/extractOptionsFromScript.js @@ -226,7 +226,7 @@ function extractOptionsFromScript(window, optsArgs = { url.pathname = getUnprefixedPathname(window, domainSourcePrefix, url.pathname); alternateLinkTag.href = url.href; } - if (translationMode == "path") { + if (translationMode == "subdirectory") { // remove lang param url.searchParams.delete(langParam); diff --git a/replaceLinks.js b/replaceLinks.js index d187e21..f98e44a 100644 --- a/replaceLinks.js +++ b/replaceLinks.js @@ -42,7 +42,7 @@ function replaceLinks(window, {langParam, lang, translationMode, prefix}) { // Update the href of the anchor tag anchor.href = url.href; - } else if (translationMode == 'path') { + } else if (translationMode == 'subdirectory') { // Create a new URL object let url = new URL(anchor.href); diff --git a/utils/selector/createLanguageSelect.js b/utils/selector/createLanguageSelect.js index db0c66f..26027d7 100644 --- a/utils/selector/createLanguageSelect.js +++ b/utils/selector/createLanguageSelect.js @@ -32,7 +32,7 @@ function addOrReplaceLangParam(window, url, lang) { return newUrl; } - if (options.translationMode == "path") { + if (options.translationMode == "subdirectory") { let pathnames = urlObj.pathname.split('/'); pathnames.splice(1, 0, lang); urlObj.pathname = pathnames.join('/'); diff --git a/utils/translation/isStillSameLang.js b/utils/translation/isStillSameLang.js index b3af120..2c68aa4 100644 --- a/utils/translation/isStillSameLang.js +++ b/utils/translation/isStillSameLang.js @@ -10,7 +10,7 @@ function getActiveLang(window) { return subdomain; } - if (options.translationMode == "path") { + if (options.translationMode == "subdirectory") { const path = window.location.pathname.split('/'); return path[1]; }