refactor: replace i18n HTTP requests with build-time bundling#22422
Merged
keithwillcode merged 23 commits intomainfrom Jul 12, 2025
Merged
refactor: replace i18n HTTP requests with build-time bundling#22422keithwillcode merged 23 commits intomainfrom
keithwillcode merged 23 commits intomainfrom
Conversation
- Create translationBundler.ts for build-time translation loading - Replace HTTP fetch in loadTranslations with file system reads - Add CalComVersion cache invalidation to prevent stale translations - Fix TypeScript errors in booking page components - Eliminate 60s timeout issues by removing network dependency Resolves translation timeout issues by bundling translations at build time instead of making runtime HTTP requests to /static/locales/ endpoints. Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 2 Skipped Deployments
|
|
✅ No security or compliance issues detected. Reviewed everything up to c1e0018. Security Overview
Detected Code Changes
Reply to this PR with |
Contributor
E2E results are ready! |
- Move i18n.ts and translationBundler.ts back to packages/lib/server/ - Replace all relative imports with @calcom/lib/server/i18n pattern - Fix LOCALES_PATH to point to correct directory - Maintain optimized serverless-friendly translation loading Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
…lar deps - Move all locale files from apps/web/public/static/locales to packages/lib/server/locales - Create copy-locales-static.js script to copy files during build - Update all references to use new location for build-time access - Maintain public folder copying for Next.js runtime access - Update platform atoms, scripts, and config files - Fix copy script relative path issue Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
- Fix import paths in test files updated by pre-commit hooks - Ensure all tests use correct locale import paths Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
keithwillcode
commented
Jul 11, 2025
keithwillcode
commented
Jul 11, 2025
…ver/i18n - Revert all test file imports back to @calcom/lib/server/i18n as requested - Addresses GitHub comment feedback to stick with packages/lib/server location - Fixes import paths in 6 test files that were incorrectly changed Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
- Update @calcom/web/public/static/locales/en/common.json to @calcom/lib/server/locales/en/common.json - Addresses GitHub comment about updating platform atoms vite config - Maintains correct path resolution after locale files moved to packages/lib/server Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
keithwillcode
commented
Jul 11, 2025
- Use process.cwd() instead of __dirname for locale file path resolution - Ensures locale files can be found in both development and production environments - Fixes E2E test failures caused by missing locale files in .next/server/chunks/ Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
- Change from process.cwd() to __dirname with relative paths - Ensures locale files can be found in both development and production environments - Fixes E2E test failures caused by incorrect path resolution in Next.js builds Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
- Change from __dirname to process.cwd() with relative paths - Ensures locale files can be found when bundled into Next.js server chunks - Fixes E2E test failures caused by incorrect path resolution in production environment - Follows same pattern used in getStaticProps.tsx for cross-package file access Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
… access - Change from process.cwd() to path.resolve(process.cwd(), '..', '..', 'packages/lib/server/locales') - Follows same pattern used in sendVerificationRequest.ts for cross-environment file access - Should resolve E2E test failures by ensuring locale files can be found when bundled into Next.js server chunks - Pattern navigates up from current working directory to reach packages directory consistently Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
- Replace relative path resolution with dynamic monorepo root finder - Ensures locale files can be found from any working directory (root, apps/web, apps/api/v2) - Update API v2 i18n config to use new locale path - Fixes remaining E2E test failures in API v2 and E2E (1/4) test suites Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
…l contexts - Replace __dirname with require.resolve(__filename) in monorepo root detection - Ensures locale files can be found when running from any working directory - Fixes E2E API v2 test failures where __dirname resolves to '.' instead of actual file path Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
…on in all contexts" This reverts commit b37d822.
… source of truth - Delete all common.json files from apps/web/public/static/locales/ - Eliminates developer confusion about which files are authoritative - copy-locales-static.js script now clearly the only mechanism for populating public folder - packages/lib/server/locales/ remains the definitive source of truth for translations Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
- Remove unnecessary second while loop using process.cwd() - The first loop from __dirname will always find the monorepo root - Add clear error message for fail-fast behavior if repo structure is corrupted - Improves code clarity and maintainability Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
…ttps://git-manager.devin.ai/proxy/github.com/calcom/cal.com into devin/1752247164-refactor-i18n-build-time-bundling
…calcom/cal.com into devin/1752247164-refactor-i18n-build-time-bundling
- Restore all common.json files from main branch to apps/web/public/static/locales/ - Overwrite packages/lib/server/locales/ with up-to-date translation content - Resolve merge conflicts using Benny's safer 2-step approach - Ensure translation source of truth remains in packages/lib/server/locales/ - Complete safer conflict resolution to eliminate merge conflicts on PR #22422 Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
- Update dependencies after ts-node installation for pre-commit hooks - Ensure yarn.lock reflects current dependency state - Complete translation integration process Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
… source of truth - Delete all common.json files from apps/web/public/static/locales/ - Maintain packages/lib/server/locales/ as the single source of truth for translations - copy-locales-static.js script will populate public folder during build process - Complete Benny's safer 2-step approach: restore from main, then remove duplicates - Resolve merge conflicts and eliminate developer confusion about translation file locations Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
Contributor
There was a problem hiding this comment.
cubic found 5 issues across 58 files. Review them in cubic.dev
React with 👍 or 👎 to teach cubic. Tag @cubic-dev-ai to give specific feedback.
apps/web/app/(booking-page-wrapper)/org/[orgSlug]/[user]/[type]/embed/page.tsx
Show resolved
Hide resolved
hbjORbj
approved these changes
Jul 12, 2025
3 tasks
dakshgup
added a commit
to dakshgup/cal.com
that referenced
this pull request
Jul 14, 2025
…s with build-time bundling (calcom#22422)" Originally by: hbjORbj This reverts commit 163c7ff. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Updated all localization logic and configuration to load translation files from the web app's public static directory instead of server-side directories. * Removed unused scripts and code related to previous translation bundling and copying mechanisms. * Adjusted build and test configurations to align with new locale file locations. * **Style** * Minor formatting changes in locale JSON files (e.g., removal of trailing newlines, spacing adjustments). * **Chores** * Updated workflow and configuration files to reflect new paths for localization resources. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
emrysal
pushed a commit
that referenced
this pull request
Jul 14, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactor i18n system to use build-time bundling and eliminate runtime HTTP requests
Summary
This PR refactors the i18n system to eliminate runtime HTTP requests for translation files, which were causing 60-second timeouts in production. The key changes include:
translationBundler.tsapps/web/public/static/locales/topackages/lib/server/locales/so packages don't need to reach into the web appCalComVersionfor cache busting similar to the frontend patterncopy-locales-static.jsscript to copy files to public folder during buildThe refactor maintains backward compatibility while significantly improving performance and eliminating the HTTP timeout issues.
Review & Testing Checklist for Human
This is a high-risk architectural change that requires thorough testing:
yarn buildand checking that locale files are copied toapps/web/public/static/locales/CALCOM_VERSIONand confirming translations update properlyRecommended test plan: Deploy to staging environment and test booking flows in multiple languages, especially the ones that were previously timing out.
Diagram
%%{ init : { "theme" : "default" }}%% graph TD subgraph "Translation Loading Flow" A["packages/lib/server/i18n.ts"]:::major-edit B["packages/lib/server/translationBundler.ts"]:::major-edit C["packages/lib/server/locales/{locale}/common.json"]:::major-edit D["apps/web/scripts/copy-locales-static.js"]:::major-edit E["apps/web/public/static/locales/{locale}/common.json"]:::context F["apps/web/package.json build script"]:::minor-edit end subgraph "Updated Import Paths" G["packages/platform/atoms/vite.config.ts"]:::minor-edit H["apps/api/v2/next-i18next.config.js"]:::minor-edit I["Multiple booking pages"]:::minor-edit end A -->|"dynamic import"| B B -->|"readFileSync"| C D -->|"copies during build"| E F -->|"runs copy-static"| D G -->|"updated alias"| C H -->|"updated localePath"| C I -->|"updated imports"| A subgraph Legend L1[Major Edit]:::major-edit L2[Minor Edit]:::minor-edit L3[Context/No Edit]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes