[web] i18n: refresh page when switching locale (#1368)
This commit is contained in:
parent
6b7984d146
commit
89377a0a57
|
|
@ -1,10 +1,11 @@
|
|||
import { RiTranslate2 } from 'react-icons/ri';
|
||||
import url from 'url';
|
||||
|
||||
import { useIntl } from '~/components/intl';
|
||||
import DropdownMenu from '~/components/ui/DropdownMenu';
|
||||
|
||||
import i18nLabelOptions from '~/i18n/i18nLabelOptions';
|
||||
import { useI18nPathname } from '~/next-i18nostic/src';
|
||||
import { i18nHref, useI18nPathname } from '~/next-i18nostic/src';
|
||||
|
||||
type Props = Readonly<{
|
||||
showSelected?: boolean;
|
||||
|
|
@ -45,10 +46,15 @@ export default function NavI18nDropdown({ size, showSelected }: Props) {
|
|||
{i18nLabelOptions.map(({ label, locale: localeItem }) => (
|
||||
<DropdownMenu.Item
|
||||
key={localeItem}
|
||||
href={pathname == null ? undefined : pathname}
|
||||
href={
|
||||
pathname == null
|
||||
? undefined
|
||||
: url.format(i18nHref(pathname, localeItem))
|
||||
}
|
||||
isSelected={locale === localeItem}
|
||||
label={label}
|
||||
locale={localeItem}
|
||||
refresh={true}
|
||||
/>
|
||||
))}
|
||||
</DropdownMenu>
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
import { RiTranslate2 } from 'react-icons/ri';
|
||||
import url from 'url';
|
||||
|
||||
import { useIntl } from '~/components/intl';
|
||||
import DropdownMenu from '~/components/ui/DropdownMenu';
|
||||
|
||||
import i18nLabelOptions from '~/i18n/i18nLabelOptions';
|
||||
import { useI18nPathname } from '~/next-i18nostic/src';
|
||||
import { i18nHref, useI18nPathname } from '~/next-i18nostic/src';
|
||||
|
||||
type Props = Readonly<{
|
||||
type: 'menu' | 'submenu';
|
||||
|
|
@ -28,10 +29,15 @@ export default function SidebarI18nSubMenu({ type }: Props) {
|
|||
{i18nLabelOptions.map(({ label, locale: localeItem }) => (
|
||||
<DropdownMenu.Item
|
||||
key={localeItem}
|
||||
href={pathname == null ? undefined : pathname}
|
||||
href={
|
||||
pathname == null
|
||||
? undefined
|
||||
: url.format(i18nHref(pathname, localeItem))
|
||||
}
|
||||
isSelected={locale === localeItem}
|
||||
label={label}
|
||||
locale={localeItem}
|
||||
refresh={true}
|
||||
/>
|
||||
))}
|
||||
</DropdownElement>
|
||||
|
|
|
|||
Loading…
Reference in New Issue