Copy of PR #22496: revert: "refactor: replace i18n HTTP requests with build-time bundling (#22422)"#1
Copy of PR #22496: revert: "refactor: replace i18n HTTP requests with build-time bundling (#22422)"#1
Conversation
…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 -->
|
Hey there and thank you for opening this pull request! 👋🏼 We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted. Details: |
|
cursor review |
There was a problem hiding this comment.
Bug: SSR Translation Fetching Issues
Translation loading fails during server-side rendering (SSR) because the mechanism changed from local bundling to fetching translations via HTTP from WEBAPP_URL. This can lead to failures if the WEBAPP_URL is inaccessible from the server's environment or if the server attempts to fetch assets before they are fully available.
packages/lib/server/i18n.ts#L12-L27
cal.com/packages/lib/server/i18n.ts
Lines 12 to 27 in 8f2a670
BugBot free trial expires on July 22, 2025
Learn more in the Cursor dashboard.
Was this report helpful? Give feedback by reacting with 👍 or 👎
There was a problem hiding this comment.
Greptile Summary
This PR is a reversion of a previous change (calcom#22422) that had moved i18n (internationalization) from HTTP requests to build-time bundling. The key changes include:
- Moving translation files from server-side (
packages/lib/server/locales/) back to client-side (apps/web/public/static/locales/) - Removing the translation bundling script and related build-time optimizations
- Updating all import paths and configurations to point to the new static file locations
- Standardizing line endings across all locale files by removing trailing newlines
The reversion suggests that the build-time bundling approach introduced issues or limitations that made the HTTP-based translation loading preferable. This change maintains more flexibility in translation updates without requiring full rebuilds.
Confidence score: 4 /5
- This PR is safe to merge as it reverts to a previously working implementation
- High confidence due to comprehensive changes across configuration, paths, and consistent formatting updates
- Key files to review:
packages/lib/server/i18n.ts: Verify translation loading logicapps/web/next.config.js: Check updated translation import pathsi18n.json: Confirm locale configuration paths
53 files reviewed, 7 comments
Edit PR Review Bot Settings | Greptile
| @@ -62,9 +62,9 @@ export default defineConfig(({ mode }) => { | |||
| "@calcom/platform-constants": path.resolve(__dirname, "../constants/index.ts"), | |||
| "@calcom/platform-types": path.resolve(__dirname, "../types/index.ts"), | |||
| "@calcom/platform-utils": path.resolve(__dirname, "../constants/index.ts"), | |||
There was a problem hiding this comment.
logic: @calcom/platform-utils alias points to constants/index.ts - should this be utils/index.ts instead?
| let translations; | ||
| if (eventLocale) { | ||
| const ns = "common"; | ||
| translations = await loadTranslations(eventLocale, ns); |
There was a problem hiding this comment.
style: Redundant 'ns' declaration. Use the one defined on line 70.
| let translations; | |
| if (eventLocale) { | |
| const ns = "common"; | |
| translations = await loadTranslations(eventLocale, ns); | |
| let translations; | |
| if (eventLocale) { | |
| translations = await loadTranslations(eventLocale, ns); |
| @@ -32,7 +32,7 @@ const ServerPage = async ({ params, searchParams }: ServerPageProps) => { | |||
|
|
|||
| const eventLocale = props.eventData?.interfaceLanguage; | |||
| const ns = "common"; | |||
There was a problem hiding this comment.
style: ns is redeclared on line 37. Use the existing declaration
| const ns = "common"; | |
| const eventLocale = props.eventData?.interfaceLanguage; | |
| const ns = "common"; | |
| let translations; | |
| if (eventLocale) { | |
| translations = await loadTranslations(eventLocale, ns); | |
| } |
| const ns = "common"; | ||
| let translations: Record<string, string> = {}; | ||
| let translations; |
There was a problem hiding this comment.
logic: Duplicate declaration of 'ns' constant on line 37. Remove redundant declaration.
| const ns = "common"; | |
| let translations: Record<string, string> = {}; | |
| let translations; | |
| let translations; | |
| if (eventLocale) { | |
| const ns = "common"; | |
| translations = await loadTranslations(eventLocale, ns); | |
| } |
| let translations: Record<string, string> = {}; | ||
| let translations; | ||
| if (eventLocale) { | ||
| const ns = "common"; |
There was a problem hiding this comment.
logic: Duplicate declaration of 'ns' constant that was already declared on line 70
| const ns = "common"; | |
| let translations; | |
| if (eventLocale) { | |
| translations = await loadTranslations(eventLocale, ns); |
| const config = { | ||
| // localesPath: localePath, // uncomment to run on all locales (to calculate kb savings) | ||
| localesPath: path.join("./packages/lib/server/locales", "/en"), | ||
| localesPath: path.join("./apps/website", "/public/static/locales", "/en"), |
There was a problem hiding this comment.
style: Double forward slashes in path.join() are unnecessary and may cause path resolution issues
| localesPath: path.join("./apps/website", "/public/static/locales", "/en"), | |
| localesPath: path.join("./apps/website", "public/static/locales", "en"), |
| ...i18nConfig, | ||
| localePath: path.resolve("../../packages/lib/server/locales"), | ||
| localePath: path.resolve("../../web/public/static/locales"), |
There was a problem hiding this comment.
style: Consider adding a comment explaining why we're using the web app's public directory for API locales
| */ | ||
| async function loadFallbackTranslations(): Promise<Record<string, string>> { | ||
| const cacheKey = `en-common-${CALCOM_VERSION}`; | ||
| async function loadFallbackTranslations() { |
There was a problem hiding this comment.
style: The return type Promise<Record<string, string>> is missing from the function declaration
| async function loadFallbackTranslations() { | |
| async function loadFallbackTranslations(): Promise<Record<string, string>> { |
| * @returns {Promise<Record<string, string>>} Translations object or fallback translations on failure | ||
| */ | ||
| export async function loadTranslations(_locale: string, ns: string): Promise<Record<string, string>> { | ||
| export async function loadTranslations(_locale: string, ns: string) { |
There was a problem hiding this comment.
style: Return type annotation should be explicit for public exported functions
| export async function loadTranslations(_locale: string, ns: string) { | |
| export async function loadTranslations(_locale: string, ns: string): Promise<Record<string, string>> { |
| @@ -3360,4 +3360,4 @@ | |||
| "license_key_saved": "লাইসেন্স কী সফলভাবে সংরক্ষিত হয়েছে", | |||
| "timezone_mismatch_tooltip": "আপনি আপনার প্রোফাইল টাইমজোন ({{userTimezone}}) অনুসারে রিপোর্ট দেখছেন, যখন আপনার ব্রাউজার টাইমজোন ({{browserTimezone}}) এ সেট করা আছে", | |||
| "ADD_NEW_STRINGS_ABOVE_THIS_LINE_TO_PREVENT_MERGE_CONFLICTS": "↑↑↑↑ুষান্ত" | |||
There was a problem hiding this comment.
style: The 'ADD_NEW_STRINGS_ABOVE_THIS_LINE_TO_PREVENT_MERGE_CONFLICTS' key includes Bengali characters that appear to be incorrectly appended
There was a problem hiding this comment.
Greptile Summary
This PR addresses some potential issues with the i18n HTTP request handling by updating the paths and error handling in several key components. Notable changes include:
- Improved error handling in translation loading by adding descriptive error messages
- Simplified caching logic by removing version-specific cache keys
- Adjusted how translations are loaded in the booking page wrapper
- Modified the translation loading logic to be more resilient to missing translations
These changes focus on making the translation system more robust and easier to maintain by removing complexity from the caching mechanism and improving error handling.
Confidence score: 3 /5
- The changes require careful testing of translation loading in various scenarios
- Score reflects the sensitive nature of i18n changes and potential impact on user experience
- Files needing attention:
apps/web/app/(booking-page-wrapper)/org/[orgSlug]/[user]/[type]/page.tsxpackages/lib/server/i18n.ts- Any components that dynamically load translations
56 files reviewed, no comments
Edit PR Review Bot Settings | Greptile
This is a copy of calcom#22496
Originally by: hbjORbj
This reverts commit 163c7ff.
Summary by CodeRabbit