Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: use nextjs i18n routing #19615

Draft
wants to merge 37 commits into
base: main
Choose a base branch
from
Draft

Conversation

hbjORbj
Copy link
Contributor

@hbjORbj hbjORbj commented Feb 28, 2025

What does this PR do?

  • 1st step towards replacing dependency on next-i18next and rather using Next.js routing-based i18n (ref: https://nextjs.org/docs/pages/building-your-application/routing/internationalization)
  • Moves all routes in App Router to inside the [lang] directory
  • In middleware, rewrite routes (while making sure to exclude APIs) to /{locale}/... (browser URL stays the same and does NOT show the {locale})
  • Rewrite getTranslate util (it now dynamically imports the translation json and returns it)
  • Refactor generateMetadata utils to adapt to the change
  • Left self-review comments

In #19638, we will remove next-i18next and replace all imports from it. I think we should merge this PR hand in hand with #19638

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • N/A - I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  • We need to make sure all routes are working as expected

@graphite-app graphite-app bot requested review from a team February 28, 2025 03:22
Copy link

vercel bot commented Feb 28, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Visit Preview Mar 7, 2025 3:04am
calcom-web-canary ⬜️ Ignored (Inspect) Visit Preview Mar 7, 2025 3:04am

@keithwillcode keithwillcode added consumer core area: core, team members only labels Feb 28, 2025
@hbjORbj hbjORbj marked this pull request as draft February 28, 2025 03:22
@dosubot dosubot bot added i18n area: i18n, translations performance area: performance, page load, slow, slow endpoints, loading screen, unresponsive labels Feb 28, 2025
@hbjORbj
Copy link
Contributor Author

hbjORbj commented Feb 28, 2025

TODO: Continue going top down from apps/[slug]/page

Copy link

graphite-app bot commented Feb 28, 2025

Graphite Automations

"Add consumer team as reviewer" took an action on this PR • (02/28/25)

1 reviewer was added to this PR based on Keith Williams's automation.

"Add foundation team as reviewer" took an action on this PR • (02/28/25)

1 reviewer was added to this PR based on Keith Williams's automation.

@hbjORbj
Copy link
Contributor Author

hbjORbj commented Feb 28, 2025

TODO: Continue going top down from /auth

optimizePackageImports: ["@calcom/ui"],
instrumentationHook: true,
serverActions: true,
},
i18n: {
Copy link
Contributor Author

@hbjORbj hbjORbj Feb 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed! — this was being ignored by app router anyways because app router doesn't support i18n config in next.config.js

@hbjORbj hbjORbj force-pushed the perf/use-nextjs-i18n-routing branch 2 times, most recently from 762caa3 to c53b182 Compare February 28, 2025 17:08
@hbjORbj hbjORbj force-pushed the perf/use-nextjs-i18n-routing branch from c53b182 to b712974 Compare February 28, 2025 17:08
@@ -164,7 +172,6 @@ export const config = {
// Next.js Doesn't support spread operator in config matcher, so, we must list all paths explicitly here.
// https://github.com/vercel/next.js/discussions/42458
matcher: [
"/",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed

fallbackLng: _nextI18Next?.userConfig?.i18n.defaultLocale,
});
type LocaleType = keyof typeof dictionaries;
const translationCache = new Map<string, TFunction>();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cache

@hbjORbj hbjORbj changed the title perf: use nextjs i18n routing perf: use nextjs i18n routing (1/2) Mar 3, 2025
@hbjORbj hbjORbj changed the title perf: use nextjs i18n routing (1/2) perf: use nextjs i18n routing Mar 3, 2025
Copy link
Contributor

This PR is being marked as stale due to inactivity.

@github-actions github-actions bot added the Stale label Mar 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consumer core area: core, team members only i18n area: i18n, translations performance area: performance, page load, slow, slow endpoints, loading screen, unresponsive ready-for-e2e Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants