Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
🐛 Fix issue where pages are not pre-rendered correctly (#1913)
Luke Vellad10712ba9c12
diff --git a/apps/landing/src/app/[locale]/(main)/(seo)/availability-poll/page.tsx b/apps/landing/src/app/[locale]/(main)/(seo)/availability-poll/page.tsxindex 1664b418a..9e7a1e546 100644--- a/apps/landing/src/app/[locale]/(main)/(seo)/availability-poll/page.tsx+++ b/apps/landing/src/app/[locale]/(main)/(seo)/availability-poll/page.tsx@@ -5,11 +5,8 @@ import { MarketingHero } from "@/components/home/hero";import { BigTestimonial, Marketing, MentionedBy } from "@/components/marketing";import { getTranslation } from "@/i18n/server";-export default async function Page(props: {- params: Promise<{ locale: string }>;-}) {- const params = await props.params;- const { t } = await getTranslation(params.locale, "home");+export default async function Page() {+ const { t } = await getTranslation("home");return (<Marketing><MarketingHero@@ -31,18 +28,15 @@ export default async function Page(props: {/>}/>- <Bonus t={t} />+ <Bonus /><BigTestimonial /><MentionedBy /></Marketing>);}-export async function generateMetadata(props: {- params: Promise<{ locale: string }>;-}): Promise<Metadata> {- const params = await props.params;- const { t } = await getTranslation(params.locale, "home");+export async function generateMetadata(): Promise<Metadata> {+ const { t } = await getTranslation("home");return {title: t("availabilityPollMetaTitle", {ns: "home",diff --git a/apps/landing/src/app/[locale]/(main)/(seo)/best-doodle-alternative/page.tsx b/apps/landing/src/app/[locale]/(main)/(seo)/best-doodle-alternative/page.tsxindex 7d170d65b..82cfbd7b1 100644--- a/apps/landing/src/app/[locale]/(main)/(seo)/best-doodle-alternative/page.tsx+++ b/apps/landing/src/app/[locale]/(main)/(seo)/best-doodle-alternative/page.tsx@@ -5,11 +5,8 @@ import { MarketingHero } from "@/components/home/hero";import { BigTestimonial, Marketing, MentionedBy } from "@/components/marketing";import { getTranslation } from "@/i18n/server";-export default async function Page(props: {- params: Promise<{ locale: string }>;-}) {- const params = await props.params;- const { t } = await getTranslation(params.locale, ["home"]);+export default async function Page() {+ const { t } = await getTranslation(["home"]);return (<Marketing><MarketingHero@@ -21,18 +18,15 @@ export default async function Page(props: {})}callToAction={<Trans t={t} ns="home" i18nKey="createAPoll" />}/>- <Bonus t={t} />+ <Bonus /><BigTestimonial /><MentionedBy /></Marketing>);}-export async function generateMetadata(props: {- params: Promise<{ locale: string }>;-}): Promise<Metadata> {- const params = await props.params;- const { t } = await getTranslation(params.locale, "home");+export async function generateMetadata(): Promise<Metadata> {+ const { t } = await getTranslation("home");return {title: t("doodleAlternativeMetaTitle", {ns: "home",diff --git a/apps/landing/src/app/[locale]/(main)/(seo)/free-scheduling-poll/page.tsx b/apps/landing/src/app/[locale]/(main)/(seo)/free-scheduling-poll/page.tsxindex 6c0410a19..91ae2bcec 100644--- a/apps/landing/src/app/[locale]/(main)/(seo)/free-scheduling-poll/page.tsx+++ b/apps/landing/src/app/[locale]/(main)/(seo)/free-scheduling-poll/page.tsx@@ -5,11 +5,8 @@ import { MarketingHero } from "@/components/home/hero";import { BigTestimonial, Marketing, MentionedBy } from "@/components/marketing";import { getTranslation } from "@/i18n/server";-export default async function Page(props: {- params: Promise<{ locale: string }>;-}) {- const params = await props.params;- const { t } = await getTranslation(params.locale, ["home"]);+export default async function Page() {+ const { t } = await getTranslation(["home"]);return (<Marketing><MarketingHero@@ -21,18 +18,15 @@ export default async function Page(props: {})}callToAction={<Trans t={t} ns="home" i18nKey="createASchedulingPoll" />}/>- <Bonus t={t} />+ <Bonus /><BigTestimonial /><MentionedBy /></Marketing>);}-export async function generateMetadata(props: {- params: Promise<{ locale: string }>;-}): Promise<Metadata> {- const params = await props.params;- const { t } = await getTranslation(params.locale, "home");+export async function generateMetadata(): Promise<Metadata> {+ const { t } = await getTranslation("home");return {title: t("freeSchedulingPollMetaTitle", {ns: "home",diff --git a/apps/landing/src/app/[locale]/(main)/(seo)/meeting-poll/page.tsx b/apps/landing/src/app/[locale]/(main)/(seo)/meeting-poll/page.tsxindex 339c9c9ad..7f442783f 100644--- a/apps/landing/src/app/[locale]/(main)/(seo)/meeting-poll/page.tsx+++ b/apps/landing/src/app/[locale]/(main)/(seo)/meeting-poll/page.tsx@@ -5,11 +5,8 @@ import { MarketingHero } from "@/components/home/hero";import { BigTestimonial, Marketing, MentionedBy } from "@/components/marketing";import { getTranslation } from "@/i18n/server";-export default async function Page(props: {- params: Promise<{ locale: string }>;-}) {- const params = await props.params;- const { t } = await getTranslation(params.locale, ["home"]);+export default async function Page() {+ const { t } = await getTranslation(["home"]);return (<Marketing><MarketingHero@@ -24,18 +21,15 @@ export default async function Page(props: {})}callToAction={<Trans t={t} ns="home" i18nKey="createAPoll" />}/>- <Bonus t={t} />+ <Bonus /><BigTestimonial /><MentionedBy /></Marketing>);}-export async function generateMetadata(props: {- params: Promise<{ locale: string }>;-}): Promise<Metadata> {- const params = await props.params;- const { t } = await getTranslation(params.locale, "home");+export async function generateMetadata(): Promise<Metadata> {+ const { t } = await getTranslation("home");return {title: t("meetingPollMetaTitle", {ns: "home",diff --git a/apps/landing/src/app/[locale]/(main)/(seo)/when2meet-alternative/page.tsx b/apps/landing/src/app/[locale]/(main)/(seo)/when2meet-alternative/page.tsxindex 99b43b281..0f4294cdf 100644--- a/apps/landing/src/app/[locale]/(main)/(seo)/when2meet-alternative/page.tsx+++ b/apps/landing/src/app/[locale]/(main)/(seo)/when2meet-alternative/page.tsx@@ -5,11 +5,8 @@ import { MarketingHero } from "@/components/home/hero";import { BigTestimonial, Marketing, MentionedBy } from "@/components/marketing";import { getTranslation } from "@/i18n/server";-export default async function Page(props: {- params: Promise<{ locale: string }>;-}) {- const params = await props.params;- const { t } = await getTranslation(params.locale, ["home"]);+export default async function Page() {+ const { t } = await getTranslation(["home"]);return (<Marketing><MarketingHero@@ -21,18 +18,15 @@ export default async function Page(props: {})}callToAction={<Trans t={t} ns="home" i18nKey="createASchedulingPoll" />}/>- <Bonus t={t} />+ <Bonus /><BigTestimonial /><MentionedBy /></Marketing>);}-export async function generateMetadata(props: {- params: Promise<{ locale: string }>;-}): Promise<Metadata> {- const params = await props.params;- const { t } = await getTranslation(params.locale, "home");+export async function generateMetadata(): Promise<Metadata> {+ const { t } = await getTranslation("home");return {title: t("when2meetAlternativeMetaTitle", {ns: "home",diff --git a/apps/landing/src/app/[locale]/(main)/blog/page.tsx b/apps/landing/src/app/[locale]/(main)/blog/page.tsxindex b86462785..ed8486909 100644--- a/apps/landing/src/app/[locale]/(main)/blog/page.tsx+++ b/apps/landing/src/app/[locale]/(main)/blog/page.tsx@@ -4,11 +4,8 @@ import { getTranslation } from "@/i18n/server";import { getAllPosts } from "@/lib/api";import { PostPreview } from "./post-preview";-export default async function Page(props: {- params: Promise<{ locale: string }>;-}) {- const params = await props.params;- const { t } = await getTranslation(params.locale, "blog");+export default async function Page() {+ const { t } = await getTranslation("blog");const allPosts = getAllPosts(["title","date",@@ -45,11 +42,8 @@ export default async function Page(props: {);}-export async function generateMetadata(props: {- params: Promise<{ locale: string }>;-}): Promise<Metadata> {- const params = await props.params;- const { t } = await getTranslation(params.locale, "blog");+export async function generateMetadata(): Promise<Metadata> {+ const { t } = await getTranslation("blog");return {title: t("blogTitle", {ns: "blog",diff --git a/apps/landing/src/app/[locale]/(main)/blog/post-preview.tsx b/apps/landing/src/app/[locale]/(main)/blog/post-preview.tsxindex a7c92ca94..6e27ee98c 100644--- a/apps/landing/src/app/[locale]/(main)/blog/post-preview.tsx+++ b/apps/landing/src/app/[locale]/(main)/blog/post-preview.tsx@@ -25,7 +25,6 @@ export const PostPreview = ({ title, date, excerpt, slug }: Props) => {<div className="grow"><h3 className="mb-3 font-bold text-lg tracking-tight"><Link- locale="en"as={`/blog/${slug}`}href="/blog/[slug]"className="hover:text-indigo-600 hover:underline"diff --git a/apps/landing/src/app/[locale]/(main)/layout.tsx b/apps/landing/src/app/[locale]/(main)/layout.tsxindex 4393ae000..74303abd9 100644--- a/apps/landing/src/app/[locale]/(main)/layout.tsx+++ b/apps/landing/src/app/[locale]/(main)/layout.tsx@@ -30,17 +30,10 @@ export const viewport: Viewport = {initialScale: 1,};-export default async function Root(props: {- children: React.ReactNode;- params: Promise<{ locale: string }>;-}) {- const params = await props.params;-- const { locale } = params;-+export default async function Root(props: { children: React.ReactNode }) {const { children } = props;- const { t } = await getTranslation(locale, "common");+ const { t } = await getTranslation();return (<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">diff --git a/apps/landing/src/app/[locale]/(main)/page.tsx b/apps/landing/src/app/[locale]/(main)/page.tsxindex 23a9d90b7..a83bf3401 100644--- a/apps/landing/src/app/[locale]/(main)/page.tsx+++ b/apps/landing/src/app/[locale]/(main)/page.tsx@@ -4,11 +4,8 @@ import { MarketingHero } from "@/components/home/hero";import { BigTestimonial, Marketing, MentionedBy } from "@/components/marketing";import { getTranslation } from "@/i18n/server";-export default async function Page(props: {- params: Promise<{ locale: string }>;-}) {- const params = await props.params;- const { t } = await getTranslation(params.locale, ["home", "common"]);+export default async function Page() {+ const { t } = await getTranslation(["home", "common"]);return (<Marketing><MarketingHero@@ -25,18 +22,15 @@ export default async function Page(props: {ns: "home",})}/>- <Bonus t={t} />+ <Bonus /><BigTestimonial /><MentionedBy /></Marketing>);}-export async function generateMetadata(props: {- params: Promise<{ locale: string }>;-}): Promise<Metadata> {- const params = await props.params;- const { t } = await getTranslation(params.locale, "home");+export async function generateMetadata(): Promise<Metadata> {+ const { t } = await getTranslation("home");return {title: t("metaTitle", {defaultValue: "Rallly: Group Scheduling Tool",diff --git a/apps/landing/src/app/[locale]/(main)/pricing/page.tsx b/apps/landing/src/app/[locale]/(main)/pricing/page.tsxindex ce05f5076..6af08e3dc 100644--- a/apps/landing/src/app/[locale]/(main)/pricing/page.tsx+++ b/apps/landing/src/app/[locale]/(main)/pricing/page.tsx@@ -1,4 +1,3 @@-import type { TFunction } from "i18next";import { TrendingUpIcon } from "lucide-react";import Link from "next/link";import { Trans } from "react-i18next/TransWithoutContext";@@ -8,7 +7,8 @@ import { linkToApp } from "@/lib/linkToApp";import { PriceTables } from "./pricing-table";-const FAQ = async ({ t }: { t: TFunction<"pricing"> }) => {+const FAQ = async () => {+ const { t } = await getTranslation("pricing");return (<section><h2 className="font-bold text-2xl">@@ -122,11 +122,8 @@ const FAQ = async ({ t }: { t: TFunction<"pricing"> }) => {);};-export default async function Page(props: {- params: Promise<{ locale: string }>;-}) {- const params = await props.params;- const { t } = await getTranslation(params.locale, "pricing");+export default async function Page() {+ const { t } = await getTranslation("pricing");return (<article className="mx-auto max-w-3xl space-y-6"><header className="space-y-2 sm:p-6 sm:text-center">@@ -176,16 +173,13 @@ export default async function Page(props: {</div></section><hr className="border-transparent" />- <FAQ t={t} />+ <FAQ /></article>);}-export async function generateMetadata(props: {- params: Promise<{ locale: string }>;-}) {- const params = await props.params;- const { t } = await getTranslation(params.locale, ["common", "pricing"]);+export async function generateMetadata() {+ const { t } = await getTranslation(["common", "pricing"]);return {title: t("pricing", { ns: "common", defaultValue: "Pricing" }),description: t("pricingDescription", {diff --git a/apps/landing/src/app/[locale]/layout.tsx b/apps/landing/src/app/[locale]/layout.tsxindex f5ebd554e..e33bf36ef 100644--- a/apps/landing/src/app/[locale]/layout.tsx+++ b/apps/landing/src/app/[locale]/layout.tsx@@ -8,6 +8,7 @@ import type { Metadata, Viewport } from "next";import { PostHogPageView } from "@/components/posthog-page-view";import { sans } from "@/fonts/sans";import { I18nProvider } from "@/i18n/client/i18n-provider";+import { getTranslation } from "@/i18n/server";export async function generateStaticParams() {return Object.keys(languages).map((locale) => ({ locale }));@@ -18,26 +19,25 @@ export const viewport: Viewport = {initialScale: 1,};-export default async function Root(props: {- children: React.ReactNode;- params: Promise<{ locale: string }>;-}) {- const params = await props.params;-- const { locale } = params;-+export default async function Root(props: { children: React.ReactNode }) {const { children } = props;+ const { i18n } = await getTranslation();+ const translations = i18n.store.data;+return (- <html lang={locale} className={sans.className}>+ <html lang={i18n.resolvedLanguage} className={sans.className}><body><LazyMotion features={domAnimation}>- <I18nProvider locale={locale}>- <PostHogProvider>- <PostHogPageView />+ <PostHogProvider>+ <PostHogPageView />+ <I18nProvider+ locale={i18n.resolvedLanguage}+ resources={translations}+ >{children}- </PostHogProvider>- </I18nProvider>+ </I18nProvider>+ </PostHogProvider></LazyMotion><Analytics /></body>@@ -46,5 +46,7 @@ export default async function Root(props: {}export const metadata: Metadata = {- metadataBase: new URL(process.env.NEXT_PUBLIC_BASE_URL as string),+ metadataBase: process.env.NEXT_PUBLIC_BASE_URL+ ? new URL(process.env.NEXT_PUBLIC_BASE_URL)+ : undefined,};diff --git a/apps/landing/src/app/[locale]/licensing/thank-you/page.tsx b/apps/landing/src/app/[locale]/licensing/thank-you/page.tsxindex 9d4c5571f..fcb08ca4b 100644--- a/apps/landing/src/app/[locale]/licensing/thank-you/page.tsx+++ b/apps/landing/src/app/[locale]/licensing/thank-you/page.tsx@@ -1,8 +1,10 @@import Image from "next/image";import Link from "next/link";-import { Trans } from "@/i18n/client/trans";+import { Trans } from "react-i18next/TransWithoutContext";+import { getTranslation } from "@/i18n/server";-export default function LicensingThankYouPage() {+export default async function LicensingThankYouPage() {+ const { t } = await getTranslation();return (<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">@@ -14,12 +16,14 @@ export default function LicensingThankYouPage() {<div className="space-y-4"><h1 className="font-bold text-2xl tracking-tight"><Trans+ t={t}i18nKey="licensingThankYouTitle"defaults="Thank You for Your Purchase!"/></h1><p><Trans+ t={t}i18nKey="licensingThankYouSubtitle"defaults="Your Rallly self-hosted license is confirmed. We're excited to have you on board!"/>@@ -28,10 +32,15 @@ export default function LicensingThankYouPage() {<div className="space-y-4"><h2 className="font-semibold text-xl">- <Trans i18nKey="licensingThankYouLicense" defaults="Next Steps" />+ <Trans+ t={t}+ i18nKey="licensingThankYouLicense"+ defaults="Next Steps"+ /></h2><p className="text-gray-700 dark:text-gray-300"><Trans+ t={t}i18nKey="licensingThankYouLicenseEmailed"defaults="Your license key has been sent to the email address you provided during checkout. Please check your inbox."/>@@ -44,6 +53,7 @@ export default function LicensingThankYouPage() {href="https://support.rallly.co/self-hosting/installation/docker"><Trans+ t={t}i18nKey="licensingThankYouNextStepsInstallation"defaults="Installation Guide"/>@@ -55,6 +65,7 @@ export default function LicensingThankYouPage() {href="https://support.rallly.co/self-hosting/licensing#activating-your-license"><Trans+ t={t}i18nKey="licensingThankYouNextStepsApplyLicense"defaults="How to Apply Your License"/>@@ -66,6 +77,7 @@ export default function LicensingThankYouPage() {<div className="text-muted-foreground"><p className="mb-6"><Trans+ t={t}i18nKey="licensingThankYouSupportPrompt"defaults="Need help or have questions? Visit our <0>self-hosted docs</0> or <1>contact us</1>."components={[@@ -84,6 +96,7 @@ export default function LicensingThankYouPage() {</p><Link href="/" className="hover:underline"><Trans+ t={t}i18nKey="licensingThankYouGoHomeLink"defaults="Return to Home"/>diff --git a/apps/landing/src/app/[locale]/not-found.tsx b/apps/landing/src/app/[locale]/not-found.tsxindex 74bd7788a..510d0ec0b 100644--- a/apps/landing/src/app/[locale]/not-found.tsx+++ b/apps/landing/src/app/[locale]/not-found.tsx@@ -4,7 +4,7 @@ import { getTranslation } from "@/i18n/server";export default async function Page() {// TODO (Luke Vella) [2023-11-03]: not-found doesn't have access to params right now// See: https://github.com/vercel/next.js/discussions/43179- const { t } = await getTranslation("en");+ const { t } = await getTranslation();return (<ErrorPagediff --git a/apps/landing/src/components/home/bonus.tsx b/apps/landing/src/components/home/bonus.tsxindex d9127c75e..6350bb6aa 100644--- a/apps/landing/src/components/home/bonus.tsx+++ b/apps/landing/src/components/home/bonus.tsx@@ -1,5 +1,4 @@import { prisma } from "@rallly/database";-import type { TFunction } from "i18next";import {CalendarCheck2Icon,LanguagesIcon,@@ -9,8 +8,10 @@ import {import { Trans } from "react-i18next/TransWithoutContext";import { BonusItem } from "@/components/home/bonus-item";+import { getTranslation } from "@/i18n/server";-export async function Bonus({ t }: { t: TFunction<"home" | "common"> }) {+export async function Bonus() {+ const { t } = await getTranslation();const userCount = await prisma.user.count();const roundedUserCount =userCount > 100000 ? Math.floor(userCount / 10000) * 10000 : userCount;diff --git a/apps/landing/src/components/home/hero.tsx b/apps/landing/src/components/home/hero.tsxindex d5c635fcf..cfa30f972 100644--- a/apps/landing/src/components/home/hero.tsx+++ b/apps/landing/src/components/home/hero.tsx@@ -36,7 +36,8 @@ const Screenshot = () => {className="relative z-20 mx-auto w-fit max-w-full rounded-full border bg-gray-800 px-3 py-2 text-gray-50 text-sm subpixel-antialiased shadow-huge"><Trans- i18nKey="home:createPageLikeThis"+ ns="home"+ i18nKey="createPageLikeThis"defaults="Create a page like this in seconds!"/><span className="-translate-x-1/2 absolute top-full left-1/2 z-10 h-8 w-px bg-gray-800" />@@ -87,7 +88,6 @@ export const MarketingHero = ({<header className="sm:p-8"><div><Link- locale="en"href="/blog/introducing-quick-create"className="group relative inline-flex items-center gap-x-2 rounded-full border bg-gray-50 py-1 pr-4 pl-1 text-gray-600 text-sm leading-6 hover:bg-white">@@ -96,7 +96,8 @@ export const MarketingHero = ({</Badge><span className="flex items-center gap-x-1"><Trans- i18nKey="home:quickCreateBlog"+ ns="home"+ i18nKey="quickCreateBlog"defaults="Introducing Quick Create"/><ChevronRightIcondiff --git a/apps/landing/src/components/marketing.tsx b/apps/landing/src/components/marketing.tsxindex ffa604c67..83de1f38c 100644--- a/apps/landing/src/components/marketing.tsx+++ b/apps/landing/src/components/marketing.tsx@@ -7,147 +7,6 @@ import type React from "react";import { Trans } from "@/i18n/client/trans";-// export const UsedBy = () => {-// return (-// <div>-// <h2 className="mx-auto mb-8 max-w-2xl text-center leading-relaxed">-// Trusted by some of the world's most influential companies and-// organizations-// </h2>-// <div className="flex flex-wrap justify-center gap-8">-// <div className="relative h-12 w-24 grayscale hover:grayscale-0">-// <Image-// src="/static/images/icrc-logo.svg"-// fill-// style={{ objectFit: "contain" }}-// alt="ICRC"-// />-// </div>-// <div className="relative h-12 w-24 grayscale hover:grayscale-0">-// <Image-// src="/harvard-logo.svg"-// fill-// style={{ objectFit: "contain" }}-// alt="Hardvard University"-// />-// </div>-// <div className="relative h-10 w-20 grayscale hover:grayscale-0">-// <Image-// src="/nhs-logo.svg"-// fill-// style={{ objectFit: "contain" }}-// alt="NHS"-// />-// </div>-// <div className="relative h-10 w-20 grayscale hover:grayscale-0">-// <Image-// src="/bcg-logo.svg"-// fill-// style={{ objectFit: "contain" }}-// alt="Boston Consulting Group"-// />-// </div>-// <div className="relative h-10 w-20 grayscale hover:grayscale-0">-// <Image-// src="/deloitte-logo.svg"-// fill-// style={{ objectFit: "contain" }}-// alt="Deloitte"-// />-// </div>-// <div className="relative h-10 w-20 grayscale hover:grayscale-0">-// <Image-// src="/ieee-logo.svg"-// fill-// style={{ objectFit: "contain" }}-// alt="IEEE"-// />-// </div>-// <div className="relative h-10 w-20 grayscale hover:grayscale-0">-// <Image-// src="/nasa-logo.svg"-// fill-// style={{ objectFit: "contain" }}-// alt="NASA"-// />-// </div>-// </div>-// </div>-// );-// };--// export const Testimonials = () => {-// return (-// <div>-// <h2 className="mb-12 text-center">Testimonials</h2>-// <div className="">-// {/* <Testimonial author="Dan">-// {`Rallly is the only service that meets all my needs and is 100%-// free. It's incredibly easy to use, no sign-in even required. And I-// trust rallly.co because the entire project is open source.`}-// </Testimonial>-// <Testimonial author="Robert">-// I was looking for something simple and clean (without tons of ads)-// that would be easy for me to administer and easy for others to use.-// This fit the bill perfectly.-// </Testimonial>-// <Testimonial author="Adrià">-// Awesome Doodle alternative. I love its open-source nature, and how-// easy it is to use thanks to its modern and clean UI.-// </Testimonial> */}-// </div>-// {/* <div className="mt-8 text-center">-// <Button className="rounded-full px-6" asChild>-// <Link-// target="_blank"-// href="https://www.trustpilot.com/evaluate/rallly.co"-// >-// <span>Share your experience</span>-// <ArrowRight className="size-4" />-// </Link>-// </Button>-// </div> */}-// </div>-// );-// };--// export const Testimonial = ({-// author,-// children,-// logo,-// }: React.PropsWithChildren<{ author: string; logo?: string }>) => {-// return (-// <div className="relative flex flex-col space-y-4 rounded-md bg-gray-50 px-4 py-3 shadow-sm">-// <QuoteIcon className="size-4 text-gray-400" />-// <div className="flex justify-between">-// <div className="flex flex-col gap-2">-// <div className="font-semibold">{author}</div>-// <Image-// src="/static/images/stars-5.svg"-// width={100}-// height={30}-// alt="5 stars"-// />-// </div>-// {logo ? (-// <div className="relative size-16">-// <Image src={logo} fill alt="logo" />-// </div>-// ) : null}-// </div>-// <p className="grow text-sm leading-relaxed">{children}</p>-// <div className="relative h-8 w-24">-// <Image-// src="/trustpilot-logo.svg"-// fill-// alt="TrustPilot"-// style={{ objectPosition: "left", objectFit: "contain" }}-// />-// </div>-// </div>-// );-// };-const Mention = ({logo,children,@@ -192,7 +51,8 @@ export const MentionedBy = () => {}><Trans- i18nKey="home:pcmagQuote"+ ns="home"+ i18nKey="pcmagQuote"defaults="“Set up a scheduling poll in as little time as possible.”"/></Mention>@@ -210,7 +70,8 @@ export const MentionedBy = () => {}><Trans- i18nKey="home:hubspotQuote"+ ns="home"+ i18nKey="hubspotQuote"defaults="“The simplest choice for availability polling for large groups.”"/></Mention>@@ -228,7 +89,8 @@ export const MentionedBy = () => {}><Trans- i18nKey="home:goodfirmsQuote"+ ns="home"+ i18nKey="goodfirmsQuote"defaults="“Unique in its simplicity and requires minimum interaction time.”"/></Mention>@@ -246,7 +108,8 @@ export const MentionedBy = () => {}><Trans- i18nKey="home:popsciQuote"+ ns="home"+ i18nKey="popsciQuote"defaults="“The perfect pick if you want to keep your RSVPs simple.”"/></Mention>@@ -277,7 +140,8 @@ export const BigTestimonial = () => {<div className="text-center"><p className="max-w-xl text-center font-medium text-lg leading-normal"><Trans- i18nKey="home:ericQuote"+ ns="home"+ i18nKey="ericQuote"defaults="“If your scheduling workflow lives in emails, I strongly encourage you to try and let Rallly simplify your scheduling tasks for a more organized and less stressful workday.”"/></p>@@ -287,7 +151,11 @@ export const BigTestimonial = () => {className="text-gray-500 text-sm hover:underline"href="https://www.trustpilot.com/reviews/645e1d1976733924e89d8203">- <Trans i18nKey="home:viaTrustpilot" defaults="via Trustpilot" />+ <Trans+ ns="home"+ i18nKey="viaTrustpilot"+ defaults="via Trustpilot"+ /><ArrowUpRight className="ml-1 inline size-3" /></Link></p>@@ -304,7 +172,8 @@ export const BigTestimonial = () => {<div className="font-semibold">Eric Fletcher</div><div className="text-gray-500 text-sm"><Trans- i18nKey="home:ericJobTitle"+ ns="home"+ i18nKey="ericJobTitle"defaults="Executive Assistant at MIT"/></div>diff --git a/apps/landing/src/i18n/client/i18n-provider.tsx b/apps/landing/src/i18n/client/i18n-provider.tsxindex be14e9d54..52f1557ae 100644--- a/apps/landing/src/i18n/client/i18n-provider.tsx+++ b/apps/landing/src/i18n/client/i18n-provider.tsx@@ -1,45 +1,38 @@"use client";-import i18next from "i18next";+import { defaultLocale } from "@rallly/languages";+import type { Resource } from "i18next";+import { createInstance } from "i18next";import ICU from "i18next-icu";-import resourcesToBackend from "i18next-resources-to-backend";-import type React from "react";+import React from "react";import { I18nextProvider, initReactI18next } from "react-i18next";-import { useAsync } from "react-use";--import { defaultNS, getOptions } from "../settings";--async function initTranslations(lng: string) {- const i18n = i18next- .use(initReactI18next)- .use(ICU)- .use(- resourcesToBackend(- (language: string, namespace: string) =>- import(`../../../public/locales/${language}/${namespace}.json`),- ),- );- await i18n.init(getOptions(lng));-- return i18n;-}+import { defaultNS, languages } from "../settings";export function I18nProvider({locale,+ resources,children,}: {- locale: string;+ locale?: string;+ resources?: Resource;children: React.ReactNode;}) {- const res = useAsync(async () => {- return await initTranslations(locale);- });+ const [i18n] = React.useState(() => {+ const instance = createInstance({+ supportedLngs: languages,+ fallbackLng: defaultLocale,+ lng: locale,+ fallbackNS: defaultNS,+ defaultNS,+ resources,+ });++ instance.use(initReactI18next).use(ICU).init();- if (!res.value) {- return null;- }+ return instance;+ });return (- <I18nextProvider i18n={res.value} defaultNS={defaultNS}>+ <I18nextProvider i18n={i18n} defaultNS={defaultNS}>{children}</I18nextProvider>);diff --git a/apps/landing/src/i18n/client/trans.tsx b/apps/landing/src/i18n/client/trans.tsxindex eb5450d5d..368bc3172 100644--- a/apps/landing/src/i18n/client/trans.tsx+++ b/apps/landing/src/i18n/client/trans.tsx@@ -1,9 +1,2 @@"use client";-import { Trans as BaseTrans, useTranslation } from "react-i18next";--type TransWithContextProps = Omit<React.ComponentProps<typeof BaseTrans>, "t">;--export const Trans = (props: TransWithContextProps) => {- const { t } = useTranslation(props.ns);- return <BaseTrans t={t} {...props} />;-};+export { Trans } from "react-i18next";diff --git a/apps/landing/src/i18n/client/use-translation.ts b/apps/landing/src/i18n/client/use-translation.tsindex 2e8e95c08..f081b0afb 100644--- a/apps/landing/src/i18n/client/use-translation.ts+++ b/apps/landing/src/i18n/client/use-translation.ts@@ -1,6 +1,3 @@-import type { Namespace } from "i18next";-import { useTranslation as useTranslationOrg } from "react-i18next";+"use client";-export function useTranslation(ns?: Namespace) {- return useTranslationOrg(ns);-}+export { useTranslation } from "react-i18next";diff --git a/apps/landing/src/i18n/i18next.ts b/apps/landing/src/i18n/i18next.tsnew file mode 100644index 000000000..11e996665--- /dev/null+++ b/apps/landing/src/i18n/i18next.ts@@ -0,0 +1,27 @@+import i18next from "i18next";+import ICU from "i18next-icu";+import resourcesToBackend from "i18next-resources-to-backend";+import { initReactI18next } from "react-i18next/initReactI18next";+import { defaultNS, fallbackLng, languages } from "./settings";++i18next+ .use(initReactI18next)+ .use(ICU)+ .use(+ resourcesToBackend(+ (language: string, namespace: string) =>+ import(`../../public/locales/${language}/${namespace}.json`),+ ),+ )+ .init({+ supportedLngs: languages,+ fallbackLng,+ lng: undefined, // let detect the language on client side+ fallbackNS: defaultNS,+ defaultNS,+ detection: {+ order: ["path", "htmlTag", "cookie", "navigator"],+ },+ });++export { i18next };diff --git a/apps/landing/src/i18n/middleware.ts b/apps/landing/src/i18n/middleware.tsnew file mode 100644index 000000000..dc03e5e75--- /dev/null+++ b/apps/landing/src/i18n/middleware.ts@@ -0,0 +1,71 @@+import { getPreferredLocale } from "@rallly/languages/get-preferred-locale";+import type { NextRequest } from "next/server";+import { NextResponse } from "next/server";+import { fallbackLng, headerName, languages } from "./settings";++function getLocaleFromPath(pathname: string): string | undefined {+ return languages.find(+ (loc) => pathname === `/${loc}` || pathname.startsWith(`/${loc}/`),+ );+}++function removeLocaleFromPath(pathname: string, locale: string): string {+ if (pathname === `/${locale}`) return "/";+ if (pathname.startsWith(`/${locale}/`)) {+ return pathname.slice(locale.length + 1);+ }+ return pathname;+}++function addLocaleToPath(pathname: string, locale: string): string {+ return `/${locale}${pathname}`;+}++function createLocalizedHeaders(req: NextRequest, locale: string): Headers {+ const headers = new Headers(req.headers);+ headers.set(headerName, locale);+ return headers;+}++function shouldRedirectFallbackLocale(pathname: string): boolean {+ return (+ pathname === `/${fallbackLng}` || pathname.startsWith(`/${fallbackLng}/`)+ );+}++export function i18nMiddleware(req: NextRequest) {+ const pathname = req.nextUrl.pathname;+ const newUrl = req.nextUrl.clone();++ const localeInPath = getLocaleFromPath(pathname);+ const preferredLocale = getPreferredLocale({+ acceptLanguageHeader: req.headers.get("accept-language") ?? undefined,+ });++ // Ensure we always have a valid locale, fallback to fallbackLng if needed+ const locale = localeInPath || preferredLocale || fallbackLng;+ const headers = createLocalizedHeaders(req, locale);++ // If the URL starts with the fallback language prefix, redirect to remove it+ if (shouldRedirectFallbackLocale(pathname)) {+ const pathWithoutFallback = removeLocaleFromPath(pathname, fallbackLng);+ newUrl.pathname = pathWithoutFallback;+ return NextResponse.redirect(newUrl);+ }++ // If no locale in path, handle based on preferred locale+ if (!localeInPath) {+ // If preferred locale is not fallback language, redirect to add locale prefix+ if (preferredLocale !== fallbackLng) {+ newUrl.pathname = addLocaleToPath(pathname, preferredLocale);+ return NextResponse.redirect(newUrl);+ }++ // If preferred locale is fallback language, rewrite internally to include it+ // This keeps the URL clean externally but routes internally to /[locale]/...+ newUrl.pathname = addLocaleToPath(pathname, fallbackLng);+ return NextResponse.rewrite(newUrl, { request: { headers } });+ }++ return NextResponse.next({ headers });+}diff --git a/apps/landing/src/i18n/server.ts b/apps/landing/src/i18n/server.tsindex 5e7cd2977..b1ed8786a 100644--- a/apps/landing/src/i18n/server.ts+++ b/apps/landing/src/i18n/server.ts@@ -1,34 +1,22 @@import type { Namespace } from "i18next";-import { createInstance } from "i18next";-import ICU from "i18next-icu";-import resourcesToBackend from "i18next-resources-to-backend";-import { initReactI18next } from "react-i18next/initReactI18next";--import { defaultNS, getOptions } from "./settings";--const initI18next = async (lng: string, ns: Namespace) => {- const i18nInstance = createInstance();- await i18nInstance- .use(initReactI18next)- .use(ICU)- .use(- resourcesToBackend(- (language: string, namespace: string) =>- import(`../../public/locales/${language}/${namespace}.json`),- ),- )- .init(getOptions(lng, ns));- return i18nInstance;-};+import { headers } from "next/headers";+import { defaultNS, fallbackLng, headerName } from "@/i18n/settings";+import { i18next } from "./i18next";export async function getTranslation<Ns extends Namespace>(- locale: string,- ns?: Ns,+ ns: string | string[] = defaultNS,) {- const fixedNs = ns ?? defaultNS;- const i18nextInstance = await initI18next(locale, fixedNs);+ const headerList = await headers();+ const lng = headerList.get(headerName);+ if (lng && i18next.resolvedLanguage !== lng) {+ await i18next.changeLanguage(lng);+ }++ if (ns && !i18next.hasLoadedNamespace(ns)) {+ await i18next.loadNamespaces(ns);+ }return {- t: i18nextInstance.getFixedT<Ns>(locale),- i18n: i18nextInstance,+ t: i18next.getFixedT<Ns>(lng ?? fallbackLng),+ i18n: i18next,};}diff --git a/apps/landing/src/i18n/settings.ts b/apps/landing/src/i18n/settings.tsindex b265a0372..16e932067 100644--- a/apps/landing/src/i18n/settings.ts+++ b/apps/landing/src/i18n/settings.ts@@ -4,6 +4,8 @@ import type { InitOptions, Namespace } from "i18next";export const fallbackLng = "en";export const languages = Object.keys(allLanguages);export const defaultNS = "common";+export const cookieName = "i18next";+export const headerName = "x-i18next-current-language";export function getOptions(lng = fallbackLng,diff --git a/apps/landing/src/middleware.ts b/apps/landing/src/middleware.tsindex 99a543cd3..cd1148cc3 100644--- a/apps/landing/src/middleware.ts+++ b/apps/landing/src/middleware.ts@@ -1,35 +1,8 @@-import { supportedLngs } from "@rallly/languages";-import { getPreferredLocale } from "@rallly/languages/get-preferred-locale";import type { NextRequest } from "next/server";-import { NextResponse } from "next/server";+import { i18nMiddleware } from "@/i18n/middleware";-export async function middleware(request: NextRequest) {- const { pathname } = request.nextUrl;- const localeInPath = supportedLngs.find(- (locale) => pathname.startsWith(`/${locale}/`) || pathname === `/${locale}`,- );-- if (localeInPath) {- if (localeInPath === "en") {- // redirect to the same path without the locale- const newUrl = request.nextUrl.clone();- newUrl.pathname = pathname.replace(`/${localeInPath}`, "");- return NextResponse.redirect(newUrl);- }- return;- }-- const locale = getPreferredLocale({- acceptLanguageHeader: request.headers.get("accept-language") ?? undefined,- });-- request.nextUrl.pathname = `/${locale}${pathname}`;-- if (locale === "en") {- return NextResponse.rewrite(request.nextUrl);- }-- return NextResponse.redirect(request.nextUrl);+export async function middleware(req: NextRequest) {+ return i18nMiddleware(req);}export const config = {