Skip to content

Commit b9fd0b4

Browse files
chore: add i18n in routing form pages (#7193)
* chore: add i18n in routing form pages * use existing string * add strings to en/common.json file * address comments
1 parent 0e72763 commit b9fd0b4

File tree

5 files changed

+55
-30
lines changed

5 files changed

+55
-30
lines changed

apps/web/public/static/locales/en/common.json

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1599,5 +1599,25 @@
15991599
"booking_with_payment_cancelled_already_paid": "A refund for this booking payment it's on the way.",
16001600
"booking_with_payment_cancelled_refunded": "This booking payment has been refunded.",
16011601
"booking_confirmation_failed": "Booking confirmation failed",
1602-
"get_started_zapier_templates": "Get started with Zapier templates"
1602+
"get_started_zapier_templates": "Get started with Zapier templates",
1603+
"a_routing_form": "A Routing Form",
1604+
"form_description_placeholder": "Form Description",
1605+
"keep_me_connected_with_form": "Keep me connected with the form",
1606+
"fields_in_form_duplicated":"Any changes in Router and Fields of the form being duplicated, would reflect in the duplicate.",
1607+
"form_deleted": "Form deleted",
1608+
"delete_form": "Delete Form",
1609+
"delete_form_action": "Yes, delete Form",
1610+
"delete_form_confirmation":"Are you sure you want to delete this form? Anyone who you've shared the link with will no longer be able to book using it. Also, all associated responses would be deleted.",
1611+
"typeform_redirect_url_copied": "Typeform Redirect URL copied! You can go and set the URL in Typeform form.",
1612+
"modifications_in_fields_warning": "Modifications in fields and routes of following forms will be reflected in this form.",
1613+
"connected_forms": "Connected Forms",
1614+
"form_modifications_warning": "Following forms would be affected when you modify fields or routes here.",
1615+
"responses_collection_waiting_description": "Wait for some time for responses to be collected. You can go and submit the form yourself as well.",
1616+
"this_is_what_your_users_would_see":"This is what your users would see",
1617+
"identifies_name_field": "Identifies field by this name.",
1618+
"add_1_option_per_line": "Add 1 option per line",
1619+
"select_a_router": "Select a router",
1620+
"add_a_new_route": "Add a new Route",
1621+
"no_responses_yet": "No responses yet",
1622+
"this_will_be_the_placeholder": "This will be the placeholder"
16031623
}

packages/app-store/ee/routing-forms/components/FormActions.tsx

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function NewFormDialog({ appUrl }: { appUrl: string }) {
6969
router.push(`${appUrl}/form-edit/${variables.id}`);
7070
},
7171
onError: () => {
72-
showToast(`Something went wrong`, "error");
72+
showToast(t("something_went_wrong"), "error");
7373
},
7474
onSettled: () => {
7575
utils.viewer.appRoutingForms.forms.invalidate();
@@ -109,14 +109,14 @@ function NewFormDialog({ appUrl }: { appUrl: string }) {
109109
});
110110
}}>
111111
<div className="mt-3 space-y-4">
112-
<TextField label={t("title")} required placeholder="A Routing Form" {...register("name")} />
112+
<TextField label={t("title")} required placeholder={t("a_routing_form")} {...register("name")} />
113113
<div className="mb-5">
114114
<TextAreaField
115115
id="description"
116116
label={t("description")}
117117
{...register("description")}
118118
data-testid="description"
119-
placeholder="Form Description"
119+
placeholder={t("form_description_placeholder")}
120120
/>
121121
</div>
122122
{action === "duplicate" && (
@@ -125,8 +125,8 @@ function NewFormDialog({ appUrl }: { appUrl: string }) {
125125
render={({ field: { value, onChange } }) => {
126126
return (
127127
<SettingsToggle
128-
title="Keep me connected with the form"
129-
description="Any changes in Router and Fields of the form being duplicated, would reflect in the duplicate."
128+
title={t("keep_me_connected_with_form")}
129+
description={t("fields_in_form_duplicated")}
130130
checked={value}
131131
onCheckedChange={(checked) => {
132132
onChange(checked);
@@ -184,6 +184,7 @@ function Dialogs({
184184
}) {
185185
const utils = trpc.useContext();
186186
const router = useRouter();
187+
const { t } = useLocale();
187188
const deleteMutation = trpc.viewer.appRoutingForms.deleteForm.useMutation({
188189
onMutate: async ({ id: formId }) => {
189190
await utils.viewer.appRoutingForms.forms.cancel();
@@ -195,7 +196,7 @@ function Dialogs({
195196
return { previousValue };
196197
},
197198
onSuccess: () => {
198-
showToast("Form deleted", "success");
199+
showToast(t("form_deleted"), "success");
199200
setDeleteDialogOpen(false);
200201
router.replace(`${appUrl}/forms`);
201202
},
@@ -207,7 +208,7 @@ function Dialogs({
207208
if (context?.previousValue) {
208209
utils.viewer.appRoutingForms.forms.setData(undefined, context.previousValue);
209210
}
210-
showToast(err.message || "Something went wrong", "error");
211+
showToast(err.message || t("something_went_wrong"), "error");
211212
},
212213
});
213214
return (
@@ -217,9 +218,9 @@ function Dialogs({
217218
<ConfirmationDialogContent
218219
isLoading={deleteMutation.isLoading}
219220
variety="danger"
220-
title="Delete Form"
221-
confirmBtnText="Yes, delete Form"
222-
loadingText="Yes, delete Form"
221+
title={t("delete_form")}
222+
confirmBtn={t("delete_form_action")}
223+
loadingText={t("delete_form_action")}
223224
onConfirm={(e) => {
224225
if (!deleteDialogFormId) {
225226
return;
@@ -229,8 +230,7 @@ function Dialogs({
229230
id: deleteDialogFormId,
230231
});
231232
}}>
232-
Are you sure you want to delete this form? Anyone who you&apos;ve shared the link with will no
233-
longer be able to book using it. Also, all associated responses would be deleted.
233+
{t("delete_form_confirmation")}
234234
</ConfirmationDialogContent>
235235
</Dialog>
236236
<NewFormDialog appUrl={appUrl} />
@@ -255,6 +255,7 @@ const actionsCtx = createContext({
255255
export function FormActionsProvider({ appUrl, children }: { appUrl: string; children: React.ReactNode }) {
256256
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
257257
const [deleteDialogFormId, setDeleteDialogFormId] = useState<string | null>(null);
258+
const { t } = useLocale();
258259
const utils = trpc.useContext();
259260

260261
const toggleMutation = trpc.viewer.appRoutingForms.formMutation.useMutation({
@@ -279,7 +280,7 @@ export function FormActionsProvider({ appUrl, children }: { appUrl: string; chil
279280
if (context?.previousValue) {
280281
utils.viewer.appRoutingForms.forms.setData(undefined, context.previousValue);
281282
}
282-
showToast("Something went wrong", "error");
283+
showToast(t("something_went_wrong"), "error");
283284
},
284285
});
285286

@@ -401,7 +402,7 @@ export const FormAction = forwardRef(function FormAction<T extends typeof Button
401402
copyRedirectUrl: {
402403
onClick: () => {
403404
navigator.clipboard.writeText(redirectUrl);
404-
showToast("Typeform Redirect URL copied! You can go and set the URL in Typeform form.", "success");
405+
showToast(t("typeform_redirect_url_copied"), "success");
405406
},
406407
},
407408
toggle: {

packages/app-store/ee/routing-forms/components/SingleForm.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -278,14 +278,14 @@ function SingleForm({ form, appUrl, Page }: SingleFormComponentProps) {
278278
<TextField
279279
type="text"
280280
containerClassName="mb-6"
281-
placeholder="Title"
281+
placeholder={t("title")}
282282
{...hookForm.register("name")}
283283
/>
284284
<TextAreaField
285285
rows={3}
286286
id="description"
287287
data-testid="description"
288-
placeholder="Form Description"
288+
placeholder={t("form_description_placeholder")}
289289
{...hookForm.register("description")}
290290
defaultValue={form.description || ""}
291291
/>
@@ -311,7 +311,7 @@ function SingleForm({ form, appUrl, Page }: SingleFormComponentProps) {
311311
<div className="mt-6">
312312
<div className="mb-2 block text-sm font-semibold leading-none text-black ">Routers</div>
313313
<p className="-mt-1 text-xs leading-normal text-gray-600">
314-
Modifications in fields and routes of following forms will be reflected in this form.
314+
{t("modifications_in_fields_warning")}
315315
</p>
316316
<div className="flex">
317317
{form.routers.map((router) => {
@@ -330,10 +330,10 @@ function SingleForm({ form, appUrl, Page }: SingleFormComponentProps) {
330330
{connectedForms?.length ? (
331331
<div className="mt-6">
332332
<div className="mb-2 block text-sm font-semibold leading-none text-black ">
333-
Connected Forms
333+
{t("connected_forms")}
334334
</div>
335335
<p className="-mt-1 text-xs leading-normal text-gray-600">
336-
Following forms would be affected when you modify fields or routes here
336+
{t("form_modifications_warning")}
337337
</p>
338338
<div className="flex">
339339
{connectedForms.map((router) => {
@@ -362,8 +362,8 @@ function SingleForm({ form, appUrl, Page }: SingleFormComponentProps) {
362362
<Alert
363363
className="mt-6"
364364
severity="neutral"
365-
title="No responses yet"
366-
message="Wait for some time for responses to be collected. You can go and submit the form yourself as well."
365+
title={t("no_responses_yet")}
366+
message={t("responses_collection_waiting_description")}
367367
/>
368368
</>
369369
)}

packages/app-store/ee/routing-forms/pages/form-edit/[...appPages].tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { v4 as uuidv4 } from "uuid";
66

77
import Shell from "@calcom/features/shell/Shell";
88
import classNames from "@calcom/lib/classNames";
9+
import { useLocale } from "@calcom/lib/hooks/useLocale";
910
import {
1011
BooleanToggleGroupField,
1112
Button,
@@ -85,6 +86,7 @@ function Field({
8586
appUrl: string;
8687
}) {
8788
const [identifier, _setIdentifier] = useState(hookForm.getValues(`${hookFieldNamespace}.identifier`));
89+
const { t } = useLocale();
8890

8991
const setUserChangedIdentifier = (val: string) => {
9092
_setIdentifier(val);
@@ -118,7 +120,7 @@ function Field({
118120
<TextField
119121
disabled={!!router}
120122
label="Label"
121-
placeholder="This is what your users would see"
123+
placeholder={t("this_is_what_your_users_would_see")}
122124
/**
123125
* This is a bit of a hack to make sure that for routerField, label is shown from there.
124126
* For other fields, value property is used because it exists and would take precedence
@@ -134,7 +136,7 @@ function Field({
134136
label="Identifier"
135137
name="identifier"
136138
required
137-
placeholder="Identifies field by this name."
139+
placeholder={t("identifies_name_field")}
138140
value={identifier}
139141
defaultValue={routerField?.identifier || routerField?.label}
140142
onChange={(e) => setUserChangedIdentifier(e.target.value)}
@@ -143,8 +145,8 @@ function Field({
143145
<div className="mb-6 w-full">
144146
<TextField
145147
disabled={!!router}
146-
label="Placeholder"
147-
placeholder="This will be the placeholder"
148+
label={t("placeholder")}
149+
placeholder={t("this_will_be_the_placeholder")}
148150
defaultValue={routerField?.placeholder}
149151
{...hookForm.register(`${hookFieldNamespace}.placeholder`)}
150152
/>
@@ -182,7 +184,7 @@ function Field({
182184
rows={3}
183185
label="Options"
184186
defaultValue={routerField?.selectText}
185-
placeholder="Add 1 option per line"
187+
placeholder={t("add_1_option_per_line")}
186188
{...hookForm.register(`${hookFieldNamespace}.selectText`)}
187189
/>
188190
</div>
@@ -198,7 +200,7 @@ function Field({
198200
return (
199201
<BooleanToggleGroupField
200202
disabled={!!router}
201-
label="Required"
203+
label={t("required")}
202204
value={value}
203205
onValueChange={onChange}
204206
/>

packages/app-store/ee/routing-forms/pages/route-builder/[...appPages].tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Query, Builder, Utils as QbUtils } from "react-awesome-query-builder";
66
import type { JsonTree, ImmutableTree, BuilderProps } from "react-awesome-query-builder";
77

88
import Shell from "@calcom/features/shell/Shell";
9+
import { useLocale } from "@calcom/lib/hooks/useLocale";
910
import { trpc } from "@calcom/trpc/react";
1011
import type { inferSSRProps } from "@calcom/types/inferSSRProps";
1112
import {
@@ -286,6 +287,7 @@ const Routes = ({
286287
appUrl: string;
287288
}) => {
288289
const { routes: serializedRoutes } = form;
290+
const { t } = useLocale();
289291

290292
const config = getQueryBuilderConfig(form);
291293
const [routes, setRoutes] = useState(() => {
@@ -446,10 +448,10 @@ const Routes = ({
446448
);
447449
})}
448450
<SelectField
449-
placeholder="Select a router"
451+
placeholder={t("select_a_router")}
450452
containerClassName="mb-6 data-testid-select-router"
451453
isOptionDisabled={(option) => !!option.isDisabled}
452-
label="Add a new Route"
454+
label={t("add_a_new_route")}
453455
options={routerOptions}
454456
key={mainRoutes.length}
455457
onChange={(option) => {

0 commit comments

Comments
 (0)