Skip to content

Commit

Permalink
replacing to en language
Browse files Browse the repository at this point in the history
  • Loading branch information
Agrim Jain authored and Agrim Jain committed May 28, 2024
1 parent c639a14 commit 9db8f0c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ export default function LocaleDropdownNavbarItem({
}, [pathname, selectedLocale]);

const replaceLocale = (path, newLocale) => {
const segments = path.split('/');
if (locales.includes(segments[1])) {
const segments = path.split('/').filter(Boolean);
if (locales.includes(segments[0])) {
if (newLocale === 'en') {
segments.splice(1, 1);
segments.shift();
} else {
segments[1] = newLocale;
segments[0] = newLocale;
}
} else if (newLocale !== 'en') {
segments.splice(1, 0, newLocale);
segments.unshift(newLocale);
}
return segments.join('/');
return '/' + segments.join('/');
};

const localeItems = locales.map((locale): LinkLikeNavbarItemProps => {
Expand Down

0 comments on commit 9db8f0c

Please sign in to comment.