Skip to content

Commit 6396671

Browse files
committed
i18n: display_name
1 parent a313568 commit 6396671

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

site/src/i18n/en/templatePage.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
"deleteTemplateCaption": "Once you delete a template, there is no going back. Please be certain.",
1010
"deleteCta": "Delete Template"
1111
}
12-
}
12+
},
13+
"displayNameLabel": "Display name"
1314
}

site/src/pages/TemplateSettingsPage/TemplateSettingsForm.tsx

+10-3
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ import {
1919
onChangeTrimmed,
2020
} from "util/formUtils"
2121
import * as Yup from "yup"
22+
import i18next from "i18next"
23+
import { useTranslation } from "react-i18next"
2224

2325
export const Language = {
2426
nameLabel: "Name",
25-
displayNameLabel: "Display name",
2627
descriptionLabel: "Description",
2728
defaultTtlLabel: "Auto-stop default",
2829
iconLabel: "Icon",
@@ -42,7 +43,11 @@ const MS_HOUR_CONVERSION = 3600000
4243

4344
export const validationSchema = Yup.object({
4445
name: nameValidator(Language.nameLabel),
45-
display_name: templateDisplayNameValidator(Language.displayNameLabel),
46+
display_name: templateDisplayNameValidator(
47+
i18next.t("displayNameLabel", {
48+
ns: "templatePage",
49+
}),
50+
),
4651
description: Yup.string().max(
4752
MAX_DESCRIPTION_CHAR_LIMIT,
4853
Language.descriptionMaxError,
@@ -99,6 +104,8 @@ export const TemplateSettingsForm: FC<TemplateSettingsForm> = ({
99104
const hasIcon = form.values.icon && form.values.icon !== ""
100105
const emojiButtonRef = useRef<HTMLButtonElement>(null)
101106

107+
const { t } = useTranslation("templatePage")
108+
102109
return (
103110
<form onSubmit={form.handleSubmit} aria-label={Language.formAriaLabel}>
104111
<Stack>
@@ -116,7 +123,7 @@ export const TemplateSettingsForm: FC<TemplateSettingsForm> = ({
116123
{...getFieldHelpers("display_name")}
117124
disabled={isSubmitting}
118125
fullWidth
119-
label={Language.displayNameLabel}
126+
label={t("displayNameLabel")}
120127
variant="outlined"
121128
/>
122129

site/src/pages/TemplateSettingsPage/TemplateSettingsPage.test.tsx

+6-3
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,12 @@ const fillAndSubmitForm = async ({
4141
await userEvent.clear(nameField)
4242
await userEvent.type(nameField, name)
4343

44-
const displayNameField = await screen.findByLabelText(
45-
FormLanguage.displayNameLabel,
46-
)
44+
const { t } = i18next
45+
const displayNameLabel = t("displayNameLabel", {
46+
ns: "templatePage",
47+
})
48+
49+
const displayNameField = await screen.findByLabelText(displayNameLabel)
4750
await userEvent.clear(displayNameField)
4851
await userEvent.type(displayNameField, display_name)
4952

0 commit comments

Comments
 (0)