Skip to content

Commit

Permalink
unlocalize admin panel link
Browse files Browse the repository at this point in the history
  • Loading branch information
linobino1 committed Aug 27, 2024
1 parent 4cfa2bf commit 5a47fe5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
7 changes: 6 additions & 1 deletion app/components/UserStatus/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ export const UserStatus: React.FC<Props> = ({ className }) => {
<Link to="/auth/me" className={classes.name}>
{t("signed in as {{name}}", { name: user.name })}
</Link>
<Link to="/admin" className={classes.admin} target="_blank">
<Link
to="/admin"
className={classes.admin}
target="_blank"
localize={false}
>
{t("backend")}
</Link>
</div>
Expand Down
14 changes: 11 additions & 3 deletions app/components/localized-link/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@ import { Link as RemixLink, LinkProps } from "@remix-run/react";
import { useTranslation } from "react-i18next";
import { localizeTo } from "./util/localizeTo";

export interface InternalLinkProps extends LinkProps {}
export interface InternalLinkProps extends LinkProps {
localize?: boolean;
}

const Link: React.FC<InternalLinkProps> = ({ to, ...props }) => {
const Link: React.FC<InternalLinkProps> = ({
to,
localize = true,
...props
}) => {
const { i18n } = useTranslation();
to = localizeTo(to, i18n.language);
if (localize) {
to = localizeTo(to, i18n.language);
}

return <RemixLink {...props} to={to} />;
};
Expand Down

0 comments on commit 5a47fe5

Please sign in to comment.