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 }) => { ...@@ -236,6 +236,12 @@ const EventDetails = ({ eventId, ...props }) => {
: {} : {}
} }
onChange={formChangeHandler} onChange={formChangeHandler}
renderLabel={label =>
intl.formatMessage({
id: `events.additionalFields.${label}`,
defaultMessage: label,
})
}
> >
<JsonSchemaFormFieldGroup <JsonSchemaFormFieldGroup
renderAll renderAll
......
...@@ -10,7 +10,6 @@ import { ...@@ -10,7 +10,6 @@ import {
Radio, Radio,
Checkbox, Checkbox,
} from '@material-ui/core' } from '@material-ui/core'
import { FormattedMessage } from 'gatsby-plugin-intl'
import { useForm } from './form' import { useForm } from './form'
import { warning } from '../../../utils/log' import { warning } from '../../../utils/log'
...@@ -27,6 +26,7 @@ const JsonSchemaFormField = ({ ...@@ -27,6 +26,7 @@ const JsonSchemaFormField = ({
enumSelectThreshold, enumSelectThreshold,
values, values,
onChange, onChange,
renderLabel,
getErrorsForField, getErrorsForField,
} = useForm() } = useForm()
...@@ -44,7 +44,7 @@ const JsonSchemaFormField = ({ ...@@ -44,7 +44,7 @@ const JsonSchemaFormField = ({
onChange({ name, value: e.target.value }) 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 description = descriptionProp || field.description
const help = hasErrors ? errors.join(', ') : description const help = hasErrors ? errors.join(', ') : description
...@@ -71,7 +71,7 @@ const JsonSchemaFormField = ({ ...@@ -71,7 +71,7 @@ const JsonSchemaFormField = ({
value={item} value={item}
disabled={disabled} disabled={disabled}
control={<Radio />} control={<Radio />}
label={<FormattedMessage id={item} />} label={label}
/> />
))} ))}
</RadioGroup> </RadioGroup>
...@@ -80,9 +80,7 @@ const JsonSchemaFormField = ({ ...@@ -80,9 +80,7 @@ const JsonSchemaFormField = ({
// above threshold -> render as Select field // above threshold -> render as Select field
return ( return (
<FormControl {...props}> <FormControl {...props}>
<InputLabel> <InputLabel>{label}</InputLabel>
<FormattedMessage id={label} defaultMessage={label} />
</InputLabel>
<Select <Select
native native
name={name} name={name}
...@@ -93,7 +91,7 @@ const JsonSchemaFormField = ({ ...@@ -93,7 +91,7 @@ const JsonSchemaFormField = ({
<option key="null" value={null} disabled hidden></option> <option key="null" value={null} disabled hidden></option>
{field.enum.map(item => ( {field.enum.map(item => (
<option key={item} value={item}> <option key={item} value={item}>
{item} {renderLabel(item)}
</option> </option>
))} ))}
</Select> </Select>
......
...@@ -10,6 +10,7 @@ const FormContext = React.createContext(null) ...@@ -10,6 +10,7 @@ const FormContext = React.createContext(null)
const JsonSchemaForm = ({ const JsonSchemaForm = ({
schema, schema,
onChange, onChange,
renderLabel,
enumSelectThreshold, enumSelectThreshold,
initialValues, initialValues,
initialValid, initialValid,
...@@ -144,6 +145,7 @@ const JsonSchemaForm = ({ ...@@ -144,6 +145,7 @@ const JsonSchemaForm = ({
isValid, isValid,
values, values,
onChange: changeHandler, onChange: changeHandler,
renderLabel,
getErrorsForField, getErrorsForField,
}} }}
> >
...@@ -165,6 +167,7 @@ JsonSchemaForm.propTypes = { ...@@ -165,6 +167,7 @@ JsonSchemaForm.propTypes = {
initialValid: PropTypes.bool, initialValid: PropTypes.bool,
/** Components rendered within this context */ /** Components rendered within this context */
children: PropTypes.node.isRequired, children: PropTypes.node.isRequired,
renderLabel: PropTypes.func,
} }
JsonSchemaForm.defaultProps = { JsonSchemaForm.defaultProps = {
...@@ -172,6 +175,7 @@ JsonSchemaForm.defaultProps = { ...@@ -172,6 +175,7 @@ JsonSchemaForm.defaultProps = {
initialValues: {}, initialValues: {},
initialValid: true, initialValid: true,
onChange: () => {}, onChange: () => {},
renderLabel: label => label,
} }
const useForm = () => React.useContext(FormContext) const useForm = () => React.useContext(FormContext)
......
...@@ -152,6 +152,11 @@ ...@@ -152,6 +152,11 @@
"events.signoff.action": "abmelden", "events.signoff.action": "abmelden",
"events.signoff.success": "Anmeldung gelöscht", "events.signoff.success": "Anmeldung gelöscht",
"events.signoff.failed": "Abmelden fehlgeschlagen", "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.title": "Studienunterlagen",
"studydocuments.search": "Dokumente suchen...", "studydocuments.search": "Dokumente suchen...",
"studydocuments.quickfilter.title": "Schnellfilter", "studydocuments.quickfilter.title": "Schnellfilter",
...@@ -215,7 +220,7 @@ ...@@ -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.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.oralExamProtocols": "Mündliche Prüfungsprotokolle",
"studydocuments.oralExamsCatchphrase": "Hast du mündliche Prüfungen?", "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.title": "Jobs",
"jobs.search": "Jobangebote durchsuchen...", "jobs.search": "Jobangebote durchsuchen...",
"jobs.downloadAsPdf": "PDF herunterladen", "jobs.downloadAsPdf": "PDF herunterladen",
......
...@@ -150,6 +150,8 @@ ...@@ -150,6 +150,8 @@
"events.signoff.action": "signoff", "events.signoff.action": "signoff",
"events.signoff.success": "Signoff successful", "events.signoff.success": "Signoff successful",
"events.signoff.failed": "Signoff failed", "events.signoff.failed": "Signoff failed",
"events.additionalFields.SBB Abonnement": "Public Transport",
"events.additionalFields.Food": "What do you eat?",
"studydocuments.title": "Studydocuments", "studydocuments.title": "Studydocuments",
"studydocuments.search": "Search studydocuments...", "studydocuments.search": "Search studydocuments...",
"studydocuments.quickfilter.title": "Quick Filter", "studydocuments.quickfilter.title": "Quick Filter",
...@@ -214,7 +216,7 @@ ...@@ -214,7 +216,7 @@
"studydocuments.legactLink": "Try your luck", "studydocuments.legactLink": "Try your luck",
"studydocuments.oralExamProtocol": "Oral Exams Protocols", "studydocuments.oralExamProtocol": "Oral Exams Protocols",
"studydocuments.oralExamsCatchphrase": "Do you have oral exams?", "studydocuments.oralExamsCatchphrase": "Do you have oral exams?",
"studydocuments.oralExamsLink": "more information", "studydocuments.oralExamsLink": "more information about exam protocols",
"jobs.title": "Jobs", "jobs.title": "Jobs",
"jobs.search": "Search job offers...", "jobs.search": "Search job offers...",
"jobs.downloadAsPdf": "Download PDF", "jobs.downloadAsPdf": "Download PDF",
......
Supports Markdown
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