Skip to content

Commit

Permalink
replace path mode into subdirectory
Browse files Browse the repository at this point in the history
  • Loading branch information
jemikanegara committed Oct 29, 2024
1 parent 754a5f3 commit aa7092f
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Place the following script inside your <head> 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).

Expand Down
2 changes: 1 addition & 1 deletion extractOptionsFromScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion replaceLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion utils/selector/createLanguageSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('/');
Expand Down
2 changes: 1 addition & 1 deletion utils/translation/isStillSameLang.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down

0 comments on commit aa7092f

Please sign in to comment.