Verified Commit 7e297ad7 authored by Sandro Lutz's avatar Sandro Lutz
Browse files

Improve translation of event signup form

parent a1216810
......@@ -236,6 +236,12 @@ const EventDetails = ({ eventId, ...props }) => {
: {}
}
onChange={formChangeHandler}
renderLabel={label =>
intl.formatMessage({
id: `events.additionalFields.${label}`,
defaultMessage: label,
})
}
>
<JsonSchemaFormFieldGroup
renderAll
......
......@@ -10,7 +10,6 @@ import {
Radio,
Checkbox,
} from '@material-ui/core'
import { FormattedMessage } from 'gatsby-plugin-intl'
import { useForm } from './form'
import { warning } from '../../../utils/log'
......@@ -27,6 +26,7 @@ const JsonSchemaFormField = ({
enumSelectThreshold,
values,
onChange,
renderLabel,
getErrorsForField,
} = useForm()
......@@ -44,7 +44,7 @@ const JsonSchemaFormField = ({
onChange({ name, value: e.target.value })
}
const label = labelProp || field.label || field.title || name
const label = renderLabel(labelProp || field.label || field.title || name)
const description = descriptionProp || field.description
const help = hasErrors ? errors.join(', ') : description
......@@ -71,7 +71,7 @@ const JsonSchemaFormField = ({
value={item}
disabled={disabled}
control={<Radio />}
label={<FormattedMessage id={item} />}
label={label}
/>
))}
</RadioGroup>
......@@ -80,9 +80,7 @@ const JsonSchemaFormField = ({
// above threshold -> render as Select field
return (
<FormControl {...props}>
<InputLabel>
<FormattedMessage id={label} defaultMessage={label} />
</InputLabel>
<InputLabel>{label}</InputLabel>
<Select
native
name={name}
......@@ -93,7 +91,7 @@ const JsonSchemaFormField = ({
<option key="null" value={null} disabled hidden></option>
{field.enum.map(item => (
<option key={item} value={item}>
{item}
{renderLabel(item)}
</option>
))}
</Select>
......
......@@ -10,6 +10,7 @@ const FormContext = React.createContext(null)
const JsonSchemaForm = ({
schema,
onChange,
renderLabel,
enumSelectThreshold,
initialValues,
initialValid,
......@@ -144,6 +145,7 @@ const JsonSchemaForm = ({
isValid,
values,
onChange: changeHandler,
renderLabel,
getErrorsForField,
}}
>
......@@ -165,6 +167,7 @@ JsonSchemaForm.propTypes = {
initialValid: PropTypes.bool,
/** Components rendered within this context */
children: PropTypes.node.isRequired,
renderLabel: PropTypes.func,
}
JsonSchemaForm.defaultProps = {
......@@ -172,6 +175,7 @@ JsonSchemaForm.defaultProps = {
initialValues: {},
initialValid: true,
onChange: () => {},
renderLabel: label => label,
}
const useForm = () => React.useContext(FormContext)
......
......@@ -152,6 +152,11 @@
"events.signoff.action": "abmelden",
"events.signoff.success": "Anmeldung gelöscht",
"events.signoff.failed": "Abmelden fehlgeschlagen",
"events.additionalFields.SBB Abonnement": "SBB Abonnement",
"events.additionalFields.Food": "Was isst du?",
"events.additionalFields.Special Food Requirements": "Spezielle Lebensmittelanforderungen",
"events.additionalFields.None": "Nichts",
"events.additionalFields.Other": "Anderes",
"studydocuments.title": "Studienunterlagen",
"studydocuments.search": "Dokumente suchen...",
"studydocuments.quickfilter.title": "Schnellfilter",
......@@ -215,7 +220,7 @@
"studydocuments.legacyText": "Du hast das gesuchte Dokument nicht gefunden? Schau auf der <a href=\"https://legacy.amiv.ethz.ch/studium/unterlagen\" target=\"_blank\">alten Webseite</a>.",
"studydocuments.oralExamProtocols": "Mündliche Prüfungsprotokolle",
"studydocuments.oralExamsCatchphrase": "Hast du mündliche Prüfungen?",
"studydocuments.oralExamsLink": "Hier gibt's weitere Informationen",
"studydocuments.oralExamsLink": "Hier gibt's Infos zu Prüfungsprotokollen",
"jobs.title": "Jobs",
"jobs.search": "Jobangebote durchsuchen...",
"jobs.downloadAsPdf": "PDF herunterladen",
......
......@@ -150,6 +150,8 @@
"events.signoff.action": "signoff",
"events.signoff.success": "Signoff successful",
"events.signoff.failed": "Signoff failed",
"events.additionalFields.SBB Abonnement": "Public Transport",
"events.additionalFields.Food": "What do you eat?",
"studydocuments.title": "Studydocuments",
"studydocuments.search": "Search studydocuments...",
"studydocuments.quickfilter.title": "Quick Filter",
......@@ -214,7 +216,7 @@
"studydocuments.legactLink": "Try your luck",
"studydocuments.oralExamProtocol": "Oral Exams Protocols",
"studydocuments.oralExamsCatchphrase": "Do you have oral exams?",
"studydocuments.oralExamsLink": "more information",
"studydocuments.oralExamsLink": "more information about exam protocols",
"jobs.title": "Jobs",
"jobs.search": "Search job offers...",
"jobs.downloadAsPdf": "Download PDF",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment