Skip to content

Commit

Permalink
fix cypress test
Browse files Browse the repository at this point in the history
  • Loading branch information
jpelay committed Nov 8, 2024
1 parent 9844aad commit ca1a343
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 10 deletions.
26 changes: 22 additions & 4 deletions static/js/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1561,10 +1561,28 @@ export function toggle_blur_code() {
}

export async function change_language(lang: string) {
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
urlParams.set('keyword_language', lang);
location.href = `${location.protocol}//${lang}.${theDomainName}${location.pathname}?${urlParams.toString()}`
if (theDomainName.includes('localhost')) {
await tryCatchPopup(async () => {
const response = await postJson('/change_language', { lang });
if (response) {
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);

if (lang === 'en' || urlParams.get("language") !== null) {
urlParams.set("language", lang)
urlParams.set('keyword_language', lang);
window.location.search = urlParams.toString();
} else {
location.reload();
}
}
});
} else {
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
urlParams.set('keyword_language', lang);
location.href = `${location.protocol}//${lang}.${theDomainName}${location.pathname}?${urlParams.toString()}`
}
}

function update_view(selector_container: string, new_lang: string) {
Expand Down
25 changes: 21 additions & 4 deletions static/js/appbundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -121714,10 +121714,27 @@ def note_with_error(value, err):
}
}
async function change_language(lang) {
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
urlParams.set("keyword_language", lang);
location.href = `${location.protocol}//${lang}.${theDomainName}${location.pathname}?${urlParams.toString()}`;
if (theDomainName.includes("localhost")) {
await tryCatchPopup(async () => {
const response = await postJson("/change_language", { lang });
if (response) {
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
if (lang === "en" || urlParams.get("language") !== null) {
urlParams.set("language", lang);
urlParams.set("keyword_language", lang);
window.location.search = urlParams.toString();
} else {
location.reload();
}
}
});
} else {
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
urlParams.set("keyword_language", lang);
location.href = `${location.protocol}//${lang}.${theDomainName}${location.pathname}?${urlParams.toString()}`;
}
}
function update_view(selector_container, new_lang) {
$("#" + selector_container + " > div").map(function() {
Expand Down
4 changes: 2 additions & 2 deletions static/js/appbundle.js.map

Large diffs are not rendered by default.

0 comments on commit ca1a343

Please sign in to comment.