Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion trunk/localizejs.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ function addLanguageToLinks() {
const EXCLUDED_PATHS = ['wp-content', 'wp-admin'];
// only use if subdirectories seo is set and plain permalinks aren't set, i.e. /es/my-page/ and not ?p=4&lang=es
if (URL_OPTIONS == '1' && localize_conf.permalink_plain != '1') {
const links = document.querySelectorAll('a');
const links = document.querySelectorAll('a:not([data-localize-ignore])');
links.forEach((link) => {
if (link.href) {
let url = new URL(link.href);
Expand All @@ -159,8 +159,10 @@ function addLanguageToLinks() {
// so, we go ahead and remove the language if it exists.
const lang = findLanguageInPath(url.pathname);
if (lang) {
link.setAttribute('data-localize-original-url', link.href );
url.pathname = removeLanguageFromPath(url.pathname);
link.href = url.href;

}
return;
}
Expand All @@ -171,6 +173,7 @@ function addLanguageToLinks() {
const docUrl = new URL(document.URL);
const docLang = findLanguageInPath(docUrl.pathname);
if (docLang) {
link.setAttribute('data-localize-original-url', link.href );
url.pathname = `/${docLang}${url.pathname}`;
link.href = url.href;
}
Expand Down