fix: event location not translated in booking page (#7528)

* fix: event location not translated

* fix: translate

* chore: lowercase trans keys

* fix: label

* feat: snake case labels

* fix: show the link if the user has one

* fix: add translatable keys

* fix:

* chore: fix type error

---------

Co-authored-by: Peer Richelsen <peeroke@gmail.com>
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
Co-authored-by: Efraín Rochín <roae.85@gmail.com>
Co-authored-by: Alex van Andel <me@alexvanandel.com>
This commit is contained in:
Nafees Nazik 2023-03-08 04:07:56 +05:30 committed by GitHub
parent 1b468b9ae7
commit b0da827483
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 92 additions and 86 deletions

View File

@ -1,3 +1,5 @@
import { z } from "zod";
import { getEventLocationType, locationKeyToString } from "@calcom/app-store/locations";
import { classNames } from "@calcom/lib";
import { useLocale } from "@calcom/lib/hooks/useLocale";
@ -17,6 +19,23 @@ export function AvailableEventLocations({ locations }: { locations: Props["event
// It's possible that the location app got uninstalled
return null;
}
const translateAbleKeys = [
"attendee_in_person",
"in_person",
"attendee_phone_number",
"link_meeting",
"organizer_phone_number",
];
const locationKey = z.string().default("").parse(locationKeyToString(location));
const translatedLocation = location.type.startsWith("integrations:")
? eventLocationType.label
: translateAbleKeys.includes(locationKey)
? t(locationKey)
: locationKey;
return (
<div key={`${location.type}-${index}`} className="flex flex-row items-center text-sm font-medium">
{eventLocationType.iconUrl === "/link.svg" ? (
@ -31,14 +50,12 @@ export function AvailableEventLocations({ locations }: { locations: Props["event
alt={`${eventLocationType.label} icon`}
/>
)}
<Tooltip content={t(locationKeyToString(location) ?? "")}>
<p className="line-clamp-1">{t(locationKeyToString(location) ?? "")}</p>
<Tooltip content={translatedLocation}>
<p className="line-clamp-1">{translatedLocation}</p>
</Tooltip>
</div>
);
})}
</div>
) : (
<></>
);
) : null;
}

View File

@ -288,16 +288,13 @@ export const EditLocationDialog = (props: ISetLocationDialog) => {
}}>
<QueryCell
query={locationsQuery}
success={({ data: locationOptions }) => {
if (!locationOptions.length) return null;
success={({ data }) => {
if (!data.length) return null;
const locationOptions = [...data];
if (booking) {
locationOptions.forEach((location) => {
if (location.label === "phone") {
location.options.filter((l) => l.value !== "phone");
} else if (location.label === "in person") {
location.options.filter((l) => l.value !== "attendeeInPerson");
}
});
locationOptions.map((location) =>
location.options.filter((l) => !["phone", "attendeeInPerson"].includes(l.value))
);
}
return (
<Controller

View File

@ -192,11 +192,9 @@ export const EventSetupTab = (
if (!eventLocationType) {
return null;
}
// We dont want to translate the string link - it doesnt exist in common.json and it gets prefixed/suffixed with __ or //
const eventLabel =
eventLocationType.defaultValueVariable === "link"
? eventLocationType.label
: t(location[eventLocationType.defaultValueVariable] || eventLocationType.label);
location[eventLocationType.defaultValueVariable] || t(eventLocationType.label);
return (
<li

View File

@ -477,8 +477,8 @@
"booking_confirmation": "قم بتأكيد {{eventTypeTitle}} مع {{profileName}}",
"booking_reschedule_confirmation": "أعد جدولة {{eventTypeTitle}} مع {{profileName}}",
"in_person_meeting": "الرابط أو الاجتماع الشخصي",
"attendeeInPerson": "شخصيًا (عنوان من سيحضر)",
"inPerson": "شخصيًا (عنوان المنظم)",
"attendee_in_person": "شخصيًا (عنوان من سيحضر)",
"in_person": "شخصيًا (عنوان المنظم)",
"link_meeting": "رابط الاجتماع",
"phone_call": "رقم هاتف الحضور",
"your_number": "رقم هاتفك",

View File

@ -470,8 +470,8 @@
"booking_confirmation": "Potvrďte {{eventTypeTitle}} skrz účet {{profileName}}",
"booking_reschedule_confirmation": "Přesunout {{eventTypeTitle}} na jindy skrz účet {{profileName}}",
"in_person_meeting": "Odkaz nebo osobní schůzka",
"attendeeInPerson": "Osobně (adresa účastníka)",
"inPerson": "Osobně (adresa organizátora)",
"attendee_in_person": "Osobně (adresa účastníka)",
"in_person": "Osobně (adresa organizátora)",
"link_meeting": "Odkaz na schůzku",
"phone_call": "Telefon",
"your_number": "Vaše telefonní číslo",

View File

@ -477,8 +477,8 @@
"booking_confirmation": "Bekræft din {{eventTypeTitle}} med {{profileName}}",
"booking_reschedule_confirmation": "Omlæg din {{eventTypeTitle}} med {{profileName}}",
"in_person_meeting": "Personligt møde",
"attendeeInPerson": "Personlig (Deltageradresse)",
"inPerson": "Personlig (Arrangøradresse)",
"attendee_in_person": "Personlig (Deltageradresse)",
"in_person": "Personlig (Arrangøradresse)",
"link_meeting": "Link møde",
"phone_call": "Deltagers Telefonnummer",
"your_number": "Dit telefonnummer",

View File

@ -477,8 +477,8 @@
"booking_confirmation": "Bestätigen Sie {{eventTypeTitle}} mit {{profileName}}",
"booking_reschedule_confirmation": "Planen Sie Ihr {{eventTypeTitle}} mit {{profileName}} um",
"in_person_meeting": "Vor-Ort-Termin",
"attendeeInPerson": "Persönlich (Teilnehmeradresse)",
"inPerson": "Persönlich (Organisator-Adresse)",
"attendee_in_person": "Persönlich (Teilnehmeradresse)",
"in_person": "Persönlich (Organisator-Adresse)",
"link_meeting": "Termin verknüpfen",
"phone_call": "Telefonat",
"your_number": "Ihre Telefonnummer",

View File

@ -478,8 +478,8 @@
"booking_confirmation": "Confirm your {{eventTypeTitle}} with {{profileName}}",
"booking_reschedule_confirmation": "Reschedule your {{eventTypeTitle}} with {{profileName}}",
"in_person_meeting": "In-person meeting",
"attendeeInPerson": "In Person (Attendee Address)",
"inPerson": "In Person (Organizer Address)",
"attendee_in_person": "In Person (Attendee Address)",
"in_person": "In Person (Organizer Address)",
"link_meeting": "Link meeting",
"phone_call": "Attendee Phone Number",
"your_number": "Your phone number",

View File

@ -470,8 +470,8 @@
"booking_confirmation": "Confirma tu {{eventTypeTitle}} con {{profileName}}",
"booking_reschedule_confirmation": "Reprogramar tu {{eventTypeTitle}} con {{profileName}}",
"in_person_meeting": "Reunión en Persona",
"attendeeInPerson": "En persona (dirección del asistente)",
"inPerson": "En persona (dirección del organizador)",
"attendee_in_person": "En persona (dirección del asistente)",
"in_person": "En persona (dirección del organizador)",
"link_meeting": "Enlace de la reunión",
"phone_call": "Número de teléfono del asistente",
"your_number": "Tu número de teléfono",

View File

@ -478,8 +478,8 @@
"booking_confirmation": "Confirmez votre {{eventTypeTitle}} avec {{profileName}}",
"booking_reschedule_confirmation": "Replanifiez votre {{eventTypeTitle}} avec {{profileName}}",
"in_person_meeting": "Rendez-vous en personne",
"attendeeInPerson": "En personne (adresse du participant)",
"inPerson": "En personne (adresse de l'organisateur)",
"attendee_in_person": "En personne (adresse du participant)",
"in_person": "En personne (adresse de l'organisateur)",
"link_meeting": "Rendez-vous avec lien",
"phone_call": "Numéro de téléphone du participant",
"your_number": "Votre numéro de téléphone",

View File

@ -478,8 +478,8 @@
"booking_confirmation": "אשר את ה{{eventTypeTitle}} עם {{profileName}}",
"booking_reschedule_confirmation": "שנה את המועד של ה{{eventTypeTitle}} עם {{profileName}}",
"in_person_meeting": "פגישה אישית",
"attendeeInPerson": "פנים-אל-פנים (בכתובת של המשתתף)",
"inPerson": "פנים-אל-פנים (בכתובת של המארגן)",
"attendee_in_person": "פנים-אל-פנים (הכתובת של המשתתף/ת)",
"in_person": "פנים-אל-פנים (הכתובת של המארגן/ת)",
"link_meeting": "פגישה עם קישור",
"phone_call": "מספר הטלפון של המשתתף/ת",
"your_number": "מספר הטלפון שלך",

View File

@ -477,8 +477,8 @@
"booking_confirmation": "Conferma il tuo {{eventTypeTitle}} con {{profileName}}",
"booking_reschedule_confirmation": "Riprogramma il tuo {{eventTypeTitle}} con {{profileName}}",
"in_person_meeting": "Link o riunione di persona",
"attendeeInPerson": "Di persona (indirizzo del partecipante)",
"inPerson": "Di persona (indirizzo dell'organizzatore)",
"attendee_in_person": "Di persona (indirizzo del partecipante)",
"in_person": "Di persona (indirizzo dell'organizzatore)",
"link_meeting": "Collegamento riunione",
"phone_call": "Numero di telefono del partecipante",
"your_number": "Il tuo numero di telefono",

View File

@ -477,8 +477,8 @@
"booking_confirmation": "{{profileName}} の{{eventTypeTitle}} を確認",
"booking_reschedule_confirmation": "{{profileName}} の {{eventTypeTitle}} をスケジュール変更する",
"in_person_meeting": "リンクまたは対面ミーティング",
"attendeeInPerson": "対面(出席者のアドレス)",
"inPerson": "対面(主催者のアドレス)",
"attendee_in_person": "対面(出席者のアドレス)",
"in_person": "対面(主催者のアドレス)",
"link_meeting": "ミーティングをリンク",
"phone_call": "出席者の電話番号",
"your_number": "あなたの電話番号",

View File

@ -477,8 +477,8 @@
"booking_confirmation": "{{profileName}}로 {{eventTypeTitle}} 확인",
"booking_reschedule_confirmation": "{{profileName}}을 사용하여 {{eventTypeTitle}} 일정을 변경하세요.",
"in_person_meeting": "온라인 또는 오프라인 회의",
"attendeeInPerson": "직접 방문(참석자 주소)",
"inPerson": "방문(주최자 주소)",
"attendee_in_person": "직접 방문(참석자 주소)",
"in_person": "방문(주최자 주소)",
"link_meeting": "회의 링크",
"phone_call": "참석자 전화 번호",
"your_number": "본인 전화 번호",

View File

@ -477,8 +477,8 @@
"booking_confirmation": "Bevestig uw {{eventTypeTitle}} met {{profileName}}",
"booking_reschedule_confirmation": "Opnieuw plannen van uw {{eventTypeTitle}} met {{profileName}}",
"in_person_meeting": "Online of persoonlijk afspreken",
"attendeeInPerson": "Persoonlijk (adres deelnemer)",
"inPerson": "Persoonlijk (adres organisator)",
"attendee_in_person": "Persoonlijk (adres deelnemer)",
"in_person": "Persoonlijk (adres organisator)",
"link_meeting": "Vergadering koppelen",
"phone_call": "Telefoonnummer deelnemer",
"your_number": "Uw telefoonnummer",

View File

@ -470,8 +470,8 @@
"booking_confirmation": "Bekreft {{eventTypeTitle}} med {{profileName}}",
"booking_reschedule_confirmation": "Endre tidspunkt for {{eventTypeTitle}} med {{profileName}}",
"in_person_meeting": "Personlig møte",
"attendeeInPerson": "Personlig Oppmøte (Deltakers Adresse)",
"inPerson": "Personlig Oppmøte (Arrangørens Adresse)",
"attendee_in_person": "Personlig Oppmøte (Deltakers Adresse)",
"in_person": "Personlig Oppmøte (Arrangørens Adresse)",
"link_meeting": "Møte lenke",
"phone_call": "Deltakers Telefonnummer",
"your_number": "Ditt telefonnummer",

View File

@ -477,8 +477,8 @@
"booking_confirmation": "Potwierdź {{eventTypeTitle}} z {{profileName}}",
"booking_reschedule_confirmation": "Przełóż Twój {{eventTypeTitle}} z {{profileName}}",
"in_person_meeting": "Link lub spotkanie osób",
"attendeeInPerson": "Osobiście (adres uczestnika)",
"inPerson": "Osobiście (adres organizatora)",
"attendee_in_person": "Osobiście (adres uczestnika)",
"in_person": "Osobiście (adres organizatora)",
"link_meeting": "Link do spotkania",
"phone_call": "Numer telefonu uczestnika",
"your_number": "Twój numer telefonu",

View File

@ -470,8 +470,8 @@
"booking_confirmation": "Confirme seu {{eventTypeTitle}} com {{profileName}}",
"booking_reschedule_confirmation": "Reagende seu {{eventTypeTitle}} com {{profileName}}",
"in_person_meeting": "Reunião presencial",
"attendeeInPerson": "Pessoalmente (endereço do participante)",
"inPerson": "Pessoalmente (endereço do organizador)",
"attendee_in_person": "Pessoalmente (endereço do participante)",
"in_person": "Pessoalmente (endereço do organizador)",
"link_meeting": "Vincular reunião",
"phone_call": "Número de telefone do participante",
"your_number": "Seu número de telefone",

View File

@ -477,8 +477,8 @@
"booking_confirmation": "Confirme o seu {{eventTypeTitle}} com {{profileName}}",
"booking_reschedule_confirmation": "Reagende o seu {{eventTypeTitle}} com {{profileName}}",
"in_person_meeting": "Ligação ou reunião presencial",
"attendeeInPerson": "Pessoalmente (endereço do participante)",
"inPerson": "Pessoalmente (endereço do organizador)",
"attendee_in_person": "Pessoalmente (endereço do participante)",
"in_person": "Pessoalmente (endereço do organizador)",
"link_meeting": "Ligar reunião",
"phone_call": "Número de telefone do participante",
"your_number": "O seu número de telefone",

View File

@ -470,8 +470,8 @@
"booking_confirmation": "Confirmă {{eventTypeTitle}} cu {{profileName}}",
"booking_reschedule_confirmation": "Reprogramează {{eventTypeTitle}} cu {{profileName}}",
"in_person_meeting": "Link sau întâlnire în persoană",
"attendeeInPerson": "În persoană (adresă participant)",
"inPerson": "În persoană (adresă organizator)",
"attendee_in_person": "În persoană (adresă participant)",
"in_person": "În persoană (adresă organizator)",
"link_meeting": "Link întâlnire",
"phone_call": "Număr de telefon participant",
"your_number": "Numărul dvs. de telefon",

View File

@ -470,8 +470,8 @@
"booking_confirmation": "Подтвердите вашу встречу «{{eventTypeTitle}}» с {{profileName}}",
"booking_reschedule_confirmation": "Перенесите вашу встречу «{{eventTypeTitle}}» с {{profileName}}",
"in_person_meeting": "Ссылка или личная встреча",
"attendeeInPerson": "Лично (адрес участника)",
"inPerson": "Лично (адрес организатора)",
"attendee_in_person": "Лично (адрес участника)",
"in_person": "Лично (адрес организатора)",
"link_meeting": "Встреча со ссылкой",
"phone_call": "Номер телефона участника",
"your_number": "Ваш номер телефона",

View File

@ -477,8 +477,8 @@
"booking_confirmation": "Potvrdite vaš {{eventTypeTitle}} sa {{profileName}}",
"booking_reschedule_confirmation": "Odložite vaš {{eventTypeTitle}} sa {{profileName}}",
"in_person_meeting": "Sastanak uživo ili preko online linka",
"attendeeInPerson": "Lično (adresa polaznika)",
"inPerson": "Lično (adresa organizatora)",
"attendee_in_person": "Lično (adresa polaznika)",
"in_person": "Lično (adresa organizatora)",
"link_meeting": "Link za sastanak",
"phone_call": "Broj telefona učesnika",
"your_number": "Vaš broj telefona",

View File

@ -477,8 +477,8 @@
"booking_confirmation": "Bekräfta {{eventTypeTitle}} med {{profileName}}",
"booking_reschedule_confirmation": "Omboka {{eventTypeTitle}} med {{profileName}}",
"in_person_meeting": "Länk eller fysiskt möte",
"attendeeInPerson": "Personligen (deltagandeadress)",
"inPerson": "Personligen (orgnanisatörsadress)",
"attendee_in_person": "Personligen (deltagandeadress)",
"in_person": "Personligen (orgnanisatörsadress)",
"link_meeting": "Länka möte",
"phone_call": "Deltagarens telefonnummer",
"your_number": "Ditt telefonnummer",

View File

@ -477,8 +477,8 @@
"booking_confirmation": "{{profileName}} ile {{eventTypeTitle}} etkinliğinizi onaylayın",
"booking_reschedule_confirmation": "{{profileName}} ile {{eventTypeTitle}} etkinliğinizi yeniden planlayın",
"in_person_meeting": "Yüz yüze görüşme",
"attendeeInPerson": "Şahsen (Katılımcı Adresi)",
"inPerson": "Şahsen (Organizatör Adresi)",
"attendee_in_person": "Şahsen (Katılımcı Adresi)",
"in_person": "Şahsen (Organizatör Adresi)",
"link_meeting": "Bağlantılı toplantı",
"phone_call": "Katılımcı Telefon Numarası",
"your_number": "Telefon numaranız",

View File

@ -477,8 +477,8 @@
"booking_confirmation": "Підтвердьте свій захід ({{eventTypeTitle}}) із користувачем {{profileName}}",
"booking_reschedule_confirmation": "Перенесіть свій захід ({{eventTypeTitle}}) із користувачем {{profileName}}",
"in_person_meeting": "Посилання або особиста зустріч",
"attendeeInPerson": "Особисто (адреса відвідувача)",
"inPerson": "Особисто (адреса організатора)",
"attendee_in_person": "Особисто (адреса відвідувача)",
"in_person": "Особисто (адреса організатора)",
"link_meeting": "Нарада з посиланням",
"phone_call": "Номер телефону учасника",
"your_number": "Ваш номер телефону",

View File

@ -477,8 +477,8 @@
"booking_confirmation": "Xác nhận {{eventTypeTitle}} của bạn với {{profileName}}",
"booking_reschedule_confirmation": "Lên lịch lại {{eventTypeTitle}} của bạn với {{profileName}}",
"in_person_meeting": "Gặp mặt trực tiếp",
"attendeeInPerson": "Đích thân (địa chỉ người tham gia)",
"inPerson": "Đích thân (địa chỉ người tổ chức)",
"attendee_in_person": "Đích thân (địa chỉ người tham gia)",
"in_person": "Đích thân (địa chỉ người tổ chức)",
"link_meeting": "Liên kết cuộc họp",
"phone_call": "Số điện thoại của người tham gia",
"your_number": "Số điện thoại của bạn",

View File

@ -477,8 +477,8 @@
"booking_confirmation": "确认您和 {{profileName}} 的 {{eventTypeTitle}}",
"booking_reschedule_confirmation": "重新安排您和 {{profileName}} 的 {{eventTypeTitle}}",
"in_person_meeting": "线上或线下会议",
"attendeeInPerson": "本人(参与者地址)",
"inPerson": "本人(组织者地址)",
"attendee_in_person": "本人(参与者地址)",
"in_person": "本人(组织者地址)",
"link_meeting": "线上会议",
"phone_call": "参与者电话号码",
"your_number": "您的电话号码",

View File

@ -470,8 +470,8 @@
"booking_confirmation": "向 {{profileName}} 確認{{eventTypeTitle}}。",
"booking_reschedule_confirmation": "向 {{profileName}} 重新預定{{eventTypeTitle}}",
"in_person_meeting": "實體會議",
"attendeeInPerson": "親自赴會 (與會者地址)",
"inPerson": "親自赴會 (主辦者地址)",
"attendee_in_person": "親自赴會 (與會者地址)",
"in_person": "親自赴會 (主辦者地址)",
"link_meeting": "線上會議",
"phone_call": "與會者電話",
"your_number": "您的電話號碼",

View File

@ -12,7 +12,7 @@ export type DefaultEventLocationType = {
type: DefaultEventLocationTypeEnum;
label: string;
messageForOrganizer: string;
category: string;
category: "in person" | "other" | "phone";
iconUrl: string;
urlRegExp?: string;
@ -66,7 +66,7 @@ export const defaultLocations: DefaultEventLocationType[] = [
{
default: true,
type: DefaultEventLocationTypeEnum.AttendeeInPerson,
label: "attendeeInPerson",
label: "attendee_in_person",
variable: "address",
organizerInputType: null,
messageForOrganizer: "Cal will ask your invitee to enter an address before scheduling.",
@ -79,7 +79,7 @@ export const defaultLocations: DefaultEventLocationType[] = [
{
default: true,
type: DefaultEventLocationTypeEnum.InPerson,
label: "inPerson",
label: "in_person",
organizerInputType: "text",
messageForOrganizer: "Provide an Address or Place",
// HACK:
@ -91,7 +91,7 @@ export const defaultLocations: DefaultEventLocationType[] = [
{
default: true,
type: DefaultEventLocationTypeEnum.Link,
label: "Link",
label: "link_meeting",
organizerInputType: "text",
variable: "locationLink",
messageForOrganizer: "Provide a Meeting Link",
@ -102,7 +102,7 @@ export const defaultLocations: DefaultEventLocationType[] = [
{
default: true,
type: DefaultEventLocationTypeEnum.Phone,
label: "Attendee Phone Number",
label: "attendee_phone_number",
variable: "phone",
organizerInputType: null,
attendeeInputType: "phone",
@ -117,7 +117,7 @@ export const defaultLocations: DefaultEventLocationType[] = [
{
default: true,
type: DefaultEventLocationTypeEnum.UserPhone,
label: "Organizer Phone Number",
label: "organizer_phone_number",
messageForOrganizer: "Provide your phone number",
organizerInputType: "phone",
variable: "locationPhoneNumber",

View File

@ -94,23 +94,17 @@ export function getLocationGroupedOptions(integrations: ReturnType<typeof getApp
// Translating labels and pushing into array
for (const category in apps) {
const tmp = { label: category, options: apps[category] };
if (tmp.label === "in person") {
tmp.options = tmp.options.map((l) => ({
const tmp = {
label: t(category),
options: apps[category].map((l) => ({
...l,
label: t(l.label),
}));
} else {
tmp.options.map((l) => ({
...l,
label: t(l.label.toLowerCase().split(" ").join("_")),
}));
}
tmp.label = t(tmp.label);
})),
};
locations.push(tmp);
}
return locations;
}