Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

@omdxp
Copy link
Contributor

@omdxp omdxp commented Dec 25, 2024

Fixes #625

  • Bug fix
  • New feature
  • Other

@omdxp omdxp self-assigned this Dec 25, 2024
@github-actions github-actions bot added fix web Web related changes ( web folder ) labels Dec 25, 2024
@omdxp omdxp marked this pull request as draft December 25, 2024 16:33
@omdxp omdxp changed the title refactor: changeLanguage function to use history API for navigation Fix switching languages at root Dec 25, 2024
// remove code from url if it's the default language
if (language.code === Languages[0].code) {
newPath = newPath.replace(`/${language.code}`, "");
newPath = newPath.replace(new RegExp(`^/${language.code}`), "") || "/";
Copy link
Member

Choose a reason for hiding this comment

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

The regex is redundant, lets remove it

/en will always be the first match, and since we're not using replaceAll, this will only replace the first match /en occurrence, which is guaranteed to be the start of the URL because of the if block we're in

@omdxp omdxp force-pushed the fix/language-switch branch from c13d798 to 82db9f7 Compare December 31, 2024 11:27
@omdxp omdxp force-pushed the fix/language-switch branch from 82db9f7 to eb7a694 Compare December 31, 2024 11:28
@omdxp omdxp marked this pull request as ready for review December 31, 2024 11:28
@omdxp omdxp requested a review from ZibanPirate December 31, 2024 11:29
@omdxp omdxp merged commit 86a8cca into main Dec 31, 2024
29 checks passed
@omdxp omdxp deleted the fix/language-switch branch December 31, 2024 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix web Web related changes ( web folder )

Projects

Status: Merged

Development

Successfully merging this pull request may close these issues.

Switching languages does not work properly

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.