Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force full page reload on language change #1291

Merged
merged 1 commit into from Feb 8, 2023

Conversation

fozziethebeat
Copy link
Collaborator

Fixes #1287 by reloading the page every time a user changes their language. When a user changes their language during the a task page, it will re-fetch the task and show either a proper task in their language or show that none exist for that task type.

@@ -37,7 +37,8 @@ const LanguageSelector = () => {
const locale = option.target.value;
setCookie("NEXT_LOCALE", locale, { path: "/" });
const path = router.asPath;
return router.push(path, path, { locale });
await router.push(path, path, { locale });
router.reload();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although it's obvious that this will work is there a better way that we can use mutate to be re-validate the task data?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now I want to make it work correctly. I will leave it to others to find a more elegant solution.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a fair point and I agree with you.

@othrayte
Copy link
Collaborator

othrayte commented Feb 7, 2023

Won't forcing the user to change task potentially throw away the content they have been writing. We currently tell the user to switch language (in a popup) if we detect it doesn't match the language that it will be submitted as.

@fozziethebeat
Copy link
Collaborator Author

Note: we discussed this a bit in discord and agreed with this sledgehammer solution. When we have to deal with intentionally multi-lingual tasks, we'll think about that more carefully.

@AbdBarho AbdBarho merged commit 7c5f463 into main Feb 8, 2023
@AbdBarho AbdBarho deleted the 1287-correct-languages-at-submission branch February 8, 2023 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Possible language changing issues
4 participants