Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

🐛 Fix i18n link issue (#1914)

Luke Vella109c3aa2b470
diff --git a/apps/landing/src/app/[locale]/(main)/footer.tsx b/apps/landing/src/app/[locale]/(main)/footer.tsx
index af36ea1da..3e7e1f722 100644
--- a/apps/landing/src/app/[locale]/(main)/footer.tsx
+++ b/apps/landing/src/app/[locale]/(main)/footer.tsx
@@ -18,6 +18,7 @@ import DiscordIcon from "@/assets/discord.svg";
import GithubIcon from "@/assets/github.svg";
import LinkedinIcon from "@/assets/linkedin.svg";
import TwitterIcon from "@/assets/twitter.svg";
+import { LinkBase } from "@/i18n/client/link";
import { Trans } from "@/i18n/client/trans";
import { useTranslation } from "@/i18n/client/use-translation";
@@ -136,49 +137,50 @@ export const Footer: React.FunctionComponent = () => {
</div>
<ul className="grid gap-2 text-sm">
<li>
- <Link
+ <LinkBase
className="inline-block font-normal text-gray-500 hover:text-gray-800 hover:no-underline"
href="/pricing"
>
<Trans i18nKey="pricing" defaults="Pricing" />
- </Link>
+ </LinkBase>
</li>
<li>
- <Link
+ <a
target="_blank"
className="inline-block font-normal text-gray-500 hover:text-gray-800 hover:no-underline"
href="https://github.com/lukevella/rallly/discussions"
+ rel="noopener"
>
<Trans
ns="common"
i18nKey="discussions"
defaults="Discussions"
/>
- </Link>
+ </a>
</li>
<li>
- <Link
- href="https://rallly.co/blog"
+ <LinkBase
+ href="/blog"
className="inline-block font-normal text-gray-500 hover:text-gray-800 hover:no-underline"
>
<Trans ns="common" i18nKey="blog" defaults="Blog" />
- </Link>
+ </LinkBase>
</li>
<li>
- <Link
+ <a
href="https://support.rallly.co"
className="inline-block font-normal text-gray-500 hover:text-gray-800 hover:no-underline"
>
<Trans ns="common" i18nKey="support" defaults="Support" />
- </Link>
+ </a>
</li>
<li>
- <Link
+ <a
href="https://rallly.openstatus.dev"
className="inline-block font-normal text-gray-500 hover:text-gray-800 hover:no-underline"
>
<Trans ns="common" i18nKey="status" defaults="Status" />
- </Link>
+ </a>
</li>
</ul>
</div>
@@ -188,7 +190,7 @@ export const Footer: React.FunctionComponent = () => {
</div>
<ul className="grid gap-2 text-sm">
<li>
- <Link
+ <LinkBase
className="inline-block font-normal text-gray-500 hover:text-gray-800 hover:no-underline"
href="/best-doodle-alternative"
>
@@ -197,10 +199,10 @@ export const Footer: React.FunctionComponent = () => {
i18nKey="bestDoodleAlternative"
defaults="Best Doodle Alternative"
/>
- </Link>
+ </LinkBase>
</li>
<li>
- <Link
+ <LinkBase
className="inline-block font-normal text-gray-500 hover:text-gray-800 hover:no-underline"
href="/when2meet-alternative"
>
@@ -209,10 +211,10 @@ export const Footer: React.FunctionComponent = () => {
i18nKey="when2MeetAlternative"
defaults="When2Meet Alternative"
/>
- </Link>
+ </LinkBase>
</li>
<li>
- <Link
+ <LinkBase
className="inline-block font-normal text-gray-500 hover:text-gray-800 hover:no-underline"
href="/free-scheduling-poll"
>
@@ -221,10 +223,10 @@ export const Footer: React.FunctionComponent = () => {
i18nKey="freeSchedulingPoll"
defaults="Free Scheduling Poll"
/>
- </Link>
+ </LinkBase>
</li>
<li>
- <Link
+ <LinkBase
className="inline-block font-normal text-gray-500 hover:text-gray-800 hover:no-underline"
href="/meeting-poll"
>
@@ -233,10 +235,10 @@ export const Footer: React.FunctionComponent = () => {
i18nKey="meetingPoll"
defaults="Meeting Poll"
/>
- </Link>
+ </LinkBase>
</li>
<li>
- <Link
+ <LinkBase
className="inline-block font-normal text-gray-500 hover:text-gray-800 hover:no-underline"
href="/availability-poll"
>
@@ -245,7 +247,7 @@ export const Footer: React.FunctionComponent = () => {
i18nKey="availabilityPoll"
defaults="Availability Poll"
/>
- </Link>
+ </LinkBase>
</li>
</ul>
</div>
diff --git a/apps/landing/src/app/[locale]/(main)/layout.tsx b/apps/landing/src/app/[locale]/(main)/layout.tsx
index 74303abd9..e70008611 100644
--- a/apps/landing/src/app/[locale]/(main)/layout.tsx
+++ b/apps/landing/src/app/[locale]/(main)/layout.tsx
@@ -12,10 +12,12 @@ import { Icon } from "@rallly/ui/icon";
import { MenuIcon } from "lucide-react";
import type { Viewport } from "next";
import Image from "next/image";
-import Link from "next/link";
+
import { Trans } from "react-i18next/TransWithoutContext";
+
import { LoginButton } from "@/components/login-button";
import { SignUpButton } from "@/components/sign-up-button";
+import { LinkBase } from "@/i18n/client/link";
import { getTranslation } from "@/i18n/server";
import { linkToApp } from "@/lib/linkToApp";
import { Footer } from "./footer";
@@ -38,9 +40,9 @@ export default async function Root(props: { children: React.ReactNode }) {
<div className="relative z-10 mx-auto flex min-h-full w-full max-w-7xl flex-col space-y-8 p-4 sm:p-8">
<header className="flex w-full items-center">
<div className="flex grow items-center gap-x-12">
- <Link className="inline-block rounded" href="/">
+ <LinkBase className="inline-block rounded" href="/">
<Image src="/logo.svg" width={130} height={30} alt="rallly.co" />
- </Link>
+ </LinkBase>
<nav className="hidden items-center gap-2 lg:flex">
<NavLink href="https://support.rallly.co/workflow/create">
<Trans t={t} i18nKey="howItWorks" defaults="How it Works" />
@@ -72,36 +74,36 @@ export default async function Root(props: { children: React.ReactNode }) {
</DropdownMenuTrigger>
<DropdownMenuContent className="w-48" align="end" sideOffset={16}>
<DropdownMenuItem asChild>
- <Link href="https://support.rallly.co/workflow/create">
+ <LinkBase href="https://support.rallly.co/workflow/create">
<Trans t={t} i18nKey="howItWorks" defaults="How it Works" />
- </Link>
+ </LinkBase>
</DropdownMenuItem>
<DropdownMenuItem asChild>
- <Link href="/pricing">
+ <LinkBase href="/pricing">
<Trans t={t} i18nKey="pricing" defaults="Pricing" />
- </Link>
+ </LinkBase>
</DropdownMenuItem>
<DropdownMenuItem asChild>
- <Link href="/blog">
+ <LinkBase href="/blog">
<Trans t={t} i18nKey="blog" />
- </Link>
+ </LinkBase>
</DropdownMenuItem>
<DropdownMenuItem asChild>
- <Link href="https://support.rallly.co">
+ <LinkBase href="https://support.rallly.co">
<Trans t={t} i18nKey="support" />
- </Link>
+ </LinkBase>
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuLabel className="space-y-2">
<Button variant="secondary" className="w-full" asChild>
- <Link href={linkToApp("/login")}>
+ <LinkBase href={linkToApp("/login")}>
<Trans t={t} i18nKey="login" defaults="Login" />
- </Link>
+ </LinkBase>
</Button>
<Button variant="primary" className="w-full" asChild>
- <Link href={linkToApp("/register")}>
+ <LinkBase href={linkToApp("/register")}>
<Trans t={t} i18nKey="signUp" defaults="Sign up" />
- </Link>
+ </LinkBase>
</Button>
</DropdownMenuLabel>
</DropdownMenuContent>
diff --git a/apps/landing/src/app/[locale]/(main)/nav-link.tsx b/apps/landing/src/app/[locale]/(main)/nav-link.tsx
index 82ec4cc70..69a172b1f 100644
--- a/apps/landing/src/app/[locale]/(main)/nav-link.tsx
+++ b/apps/landing/src/app/[locale]/(main)/nav-link.tsx
@@ -2,13 +2,13 @@
import { cn } from "@rallly/ui";
import { Button } from "@rallly/ui/button";
-import Link from "next/link";
import { usePathname } from "next/navigation";
+import { LinkBase } from "@/i18n/client/link";
export const NavLink = ({
className,
...props
-}: React.ComponentProps<typeof Link>) => {
+}: React.ComponentProps<typeof LinkBase>) => {
const pathname = usePathname();
const isActive = pathname === props.href;
return (
@@ -17,7 +17,7 @@ export const NavLink = ({
asChild
variant="ghost"
>
- <Link {...props} />
+ <LinkBase {...props} />
</Button>
);
};
diff --git a/apps/landing/src/app/[locale]/licensing/thank-you/page.tsx b/apps/landing/src/app/[locale]/licensing/thank-you/page.tsx
index fcb08ca4b..5eb3016fe 100644
--- a/apps/landing/src/app/[locale]/licensing/thank-you/page.tsx
+++ b/apps/landing/src/app/[locale]/licensing/thank-you/page.tsx
@@ -1,6 +1,6 @@
import Image from "next/image";
-import Link from "next/link";
import { Trans } from "react-i18next/TransWithoutContext";
+import { LinkBase } from "@/i18n/client/link";
import { getTranslation } from "@/i18n/server";
export default async function LicensingThankYouPage() {
@@ -9,9 +9,9 @@ export default async function LicensingThankYouPage() {
<main className="relative flex h-dvh flex-col p-4 sm:justify-center sm:p-16">
<div className="relative z-10 mx-auto w-full max-w-2xl space-y-6">
<div className="py-4">
- <Link className="inline-block rounded" href="/">
+ <LinkBase className="inline-block rounded" href="/">
<Image src="/logo.svg" width={150} height={30} alt="rallly.co" />
- </Link>
+ </LinkBase>
</div>
<div className="space-y-4">
<h1 className="font-bold text-2xl tracking-tight">
@@ -48,7 +48,7 @@ export default async function LicensingThankYouPage() {
<ul className="list-inside list-disc space-y-1">
<li>
- <Link
+ <a
className="text-link"
href="https://support.rallly.co/self-hosting/installation/docker"
>
@@ -57,10 +57,10 @@ export default async function LicensingThankYouPage() {
i18nKey="licensingThankYouNextStepsInstallation"
defaults="Installation Guide"
/>
- </Link>
+ </a>
</li>
<li>
- <Link
+ <a
className="text-link"
href="https://support.rallly.co/self-hosting/licensing#activating-your-license"
>
@@ -69,7 +69,7 @@ export default async function LicensingThankYouPage() {
i18nKey="licensingThankYouNextStepsApplyLicense"
defaults="How to Apply Your License"
/>
- </Link>
+ </a>
</li>
</ul>
</div>
@@ -81,12 +81,12 @@ export default async function LicensingThankYouPage() {
i18nKey="licensingThankYouSupportPrompt"
defaults="Need help or have questions? Visit our <0>self-hosted docs</0> or <1>contact us</1>."
components={[
- <Link
+ <a
key="self-hosted-docs"
href="https://support.rallly.co"
className="underline"
/>,
- <Link
+ <a
key="contact-us"
href="mailto:[email protected]"
className="underline"
@@ -94,13 +94,13 @@ export default async function LicensingThankYouPage() {
]}
/>
</p>
- <Link href="/" className="hover:underline">
+ <LinkBase href="/" className="hover:underline">
<Trans
t={t}
i18nKey="licensingThankYouGoHomeLink"
defaults="Return to Home"
/>
- </Link>
+ </LinkBase>
</div>
</div>
</main>
diff --git a/apps/landing/src/components/error-page.tsx b/apps/landing/src/components/error-page.tsx
index 4e7dda428..bb5884390 100644
--- a/apps/landing/src/components/error-page.tsx
+++ b/apps/landing/src/components/error-page.tsx
@@ -2,9 +2,8 @@
import { Button } from "@rallly/ui/button";
import { FileSearchIcon } from "lucide-react";
-import Link from "next/link";
import type * as React from "react";
-
+import { LinkBase } from "@/i18n/client/link";
import { useTranslation } from "@/i18n/client/use-translation";
export interface ComponentProps {
@@ -33,12 +32,10 @@ const ErrorPage: React.FunctionComponent<ComponentProps> = ({
</div>
<div className="flex justify-center space-x-3">
<Button variant="primary" asChild>
- <Link href="/">{t("goToHome")}</Link>
+ <LinkBase href="/">{t("goToHome")}</LinkBase>
</Button>
<Button asChild>
- <Link href="https://support.rallly.co" passHref={true}>
- {t("support")}
- </Link>
+ <a href="https://support.rallly.co">{t("support")}</a>
</Button>
</div>
</div>
diff --git a/apps/landing/src/i18n/client/link.tsx b/apps/landing/src/i18n/client/link.tsx
new file mode 100644
index 000000000..561d11563
--- /dev/null
+++ b/apps/landing/src/i18n/client/link.tsx
@@ -0,0 +1,24 @@
+"use client";
+
+import Link from "next/link";
+import { useTranslation } from "react-i18next";
+
+export const LinkBase = ({
+ href,
+ children,
+ className,
+}: {
+ href: string;
+ children?: React.ReactNode;
+ className?: string;
+}) => {
+ const { i18n } = useTranslation();
+ const newHref = href.startsWith("/")
+ ? `/${i18n.resolvedLanguage}${href}`
+ : href;
+ return (
+ <Link className={className} href={newHref}>
+ {children}
+ </Link>
+ );
+};
diff --git a/biome.json b/biome.json
index 2de395b02..9703691fc 100644
--- a/biome.json
+++ b/biome.json
@@ -34,6 +34,9 @@
"level": "error",
"fix": "safe"
}
+ },
+ "a11y": {
+ "useAnchorContent": "off"
}
}
},