fix: translate location dropdown group labels and options in event-type settings (#26784)

* fix: translate location dropdown group labels in event-type settings

Co-Authored-By: [email protected] <[email protected]>

* fix: use requesting user's locale for team event type translations

For team event types, the current user might not be in eventType.users,
causing translations to default to English. This fix queries the user's
locale directly from the database when not found in the event type users.

Co-Authored-By: [email protected] <[email protected]>

* refactor: pass userLocale as parameter instead of database call

Per PR feedback, pass the authenticated user's locale as an optional
parameter to getEventTypeById instead of making an extra database call.
The locale is passed from ctx.user.locale in the tRPC handler.

Co-Authored-By: [email protected] <[email protected]>

* fix: provide userLocale in apiv2 getEventTypeById

* fix: remove unused ts comments

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2026-01-14 08:28:31 -03:00
1 parent a7a8c78494
commit 0b37520f0d
7 files changed
+87 -82

No files matched your search

+11 -11
View File
@@ -1,20 +1,20 @@
/**
* TODO: Consolidate this file with BookingLocationService and add tests
*/
import type { TFunction } from "i18next";
import { isValidPhoneNumber } from "libphonenumber-js/max";
import { z } from "zod";
import { appStoreMetadata } from "@calcom/app-store/bookerAppsMetaData";
import logger from "@calcom/lib/logger";
import { BookingStatus } from "@calcom/prisma/enums";
import type { Ensure, Optional } from "@calcom/types/utils";
import type { TFunction } from "i18next";
import { isValidPhoneNumber } from "libphonenumber-js/max";
import { z } from "zod";
import type { EventLocationTypeFromAppMeta } from "../types/App";
import {
DailyLocationType as importedDailyLocationType,
MeetLocationType as importedMeetLocationType,
MSTeamsLocationType as importedMSTeamsLocationType,
DailyLocationType as importedDailyLocationType,
} from "./constants";
export const MeetLocationType = importedMeetLocationType;
@@ -26,7 +26,7 @@ export type DefaultEventLocationType = {
type: DefaultEventLocationTypeEnum;
label: string;
messageForOrganizer: string;
category: "in person" | "conferencing" | "other" | "phone";
category: "in_person_category" | "conferencing" | "other" | "phone";
linkType: "static";
supportsCustomLabel?: boolean;
@@ -114,7 +114,7 @@ export const defaultLocations: DefaultEventLocationType[] = [
attendeeInputPlaceholder: "enter_address",
defaultValueVariable: "attendeeAddress",
iconUrl: "/map-pin-dark.svg",
category: "in person",
category: "in_person_category",
linkType: "static",
supportsCustomLabel: true,
},
@@ -143,7 +143,7 @@ export const defaultLocations: DefaultEventLocationType[] = [
variable: "locationAddress",
defaultValueVariable: "address",
iconUrl: "/map-pin-dark.svg",
category: "in person",
category: "in_person_category",
linkType: "static",
},
{
@@ -242,7 +242,7 @@ for (const [appName, meta] of Object.entries(appStoreMetadata)) {
for (const [key, value] of Object.entries(location)) {
if (typeof value === "string") {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// @ts-expect-error
location[key] = value.replace(/{SLUG}/g, meta.slug).replace(/{TITLE}/g, meta.name);
}
}
@@ -397,7 +397,7 @@ export const getLocationValueForDB = (
eventLocations: LocationObject[]
) => {
let bookingLocation = bookingLocationTypeOrValue;
let conferenceCredentialId: number | undefined = undefined;
let conferenceCredentialId: number | undefined;
eventLocations.forEach((location) => {
if (location.type === bookingLocationTypeOrValue) {
@@ -481,8 +481,8 @@ export const getTranslatedLocation = (
const translatedLocation = location.type.startsWith("integrations:")
? eventLocationType.label
: translateAbleKeys.includes(locationKey)
? t(locationKey)
: locationKey;
? t(locationKey)
: locationKey;
return translatedLocation;
};