Skip to content

Commit 4a28084

Browse files
authored
i18n fixes 9 (#8200)
* Start fixing mentor-registration modal * Quick fix * Better fix
1 parent d71ef07 commit 4a28084

5 files changed

Lines changed: 65 additions & 39 deletions

File tree

app/javascript/components/modals/mentor-registration-modal/ChooseTrackStep.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import React from 'react'
44
import { TrackSelector } from '../../mentoring/TrackSelector'
55
import { useAppTranslation } from '@/i18n/useAppTranslation'
6+
import { Trans } from 'react-i18next'
67

78
export type Links = {
89
tracks: string
@@ -23,7 +24,15 @@ export const ChooseTrackStep = ({
2324
return (
2425
<section className="tracks-section">
2526
<h2>{t('chooseTrackStep.selectTracks')}</h2>
26-
<p>{t('chooseTrackStep.allowsUsToShow')}</p>
27+
<p>
28+
{
29+
<Trans
30+
i18nKey="chooseTrackStep.allowsUsToShow"
31+
ns="components/modals/mentor-registration-modal"
32+
components={[<strong />]}
33+
/>
34+
}
35+
</p>
2736
<TrackSelector
2837
tracksEndpoint={links.tracks}
2938
selected={selected}

app/javascript/components/modals/mentor-registration-modal/CommitStep.tsx

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ export const CommitStep = ({
4343
accept_terms: true,
4444
}),
4545
})
46-
4746
return fetch
4847
},
4948
onSuccess: () => {
@@ -54,16 +53,10 @@ export const CommitStep = ({
5453
const { t } = useAppTranslation('components/modals/mentor-registration-modal')
5554

5655
const [numChecked, setNumChecked] = useState(0)
57-
const handleChange = useCallback(
58-
(e) => {
59-
if (e.target.checked) {
60-
setNumChecked(numChecked + 1)
61-
} else {
62-
setNumChecked(numChecked - 1)
63-
}
64-
},
65-
[numChecked]
66-
)
56+
const handleChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
57+
const { checked } = e.target
58+
setNumChecked((prev) => (checked ? prev + 1 : prev - 1))
59+
}, [])
6760

6861
const handleSubmit = useCallback(() => {
6962
mutation()
@@ -75,47 +68,60 @@ export const CommitStep = ({
7568
<h2>{t('commitStep.title')}</h2>
7669
<p>{t('commitStep.description')}</p>
7770
<ReputationInfo />
71+
7872
<div className="commitment">
7973
<h3>{t('commitStep.youAgreeTo')}</h3>
8074

8175
<Checkbox onChange={handleChange}>
82-
<Trans
83-
ns="components/modals/mentor-registration-modal"
84-
i18nKey="commitStep.codeOfConduct"
85-
components={{
86-
a: (
76+
<span>
77+
<Trans
78+
ns="components/modals/mentor-registration-modal"
79+
i18nKey="commitStep.codeOfConduct"
80+
components={[
8781
<a
82+
key="link"
8883
href={links.codeOfConduct}
8984
target="_blank"
9085
rel="noreferrer"
91-
/>
92-
),
93-
icon: <Icon icon="external-link" alt="Opens in a new tab" />,
94-
}}
95-
/>
86+
/>,
87+
<Icon
88+
key="icon"
89+
icon="external-link"
90+
alt="Opens in a new tab"
91+
/>,
92+
]}
93+
/>
94+
</span>
9695
</Checkbox>
9796

98-
<Checkbox onChange={handleChange}>{t('commitStep.beKind')}</Checkbox>
97+
<Checkbox onChange={handleChange}>
98+
<span>{t('commitStep.beKind')}</span>
99+
</Checkbox>
99100

100101
<Checkbox onChange={handleChange}>
101-
<Trans
102-
ns="components/modals/mentor-registration-modal"
103-
i18nKey="commitStep.intellectualHumility"
104-
components={{
105-
a: (
102+
<span>
103+
<Trans
104+
ns="components/modals/mentor-registration-modal"
105+
i18nKey="commitStep.intellectualHumility"
106+
components={[
106107
<a
108+
key="link"
107109
href={links.intellectualHumility}
108110
target="_blank"
109111
rel="noreferrer"
110-
/>
111-
),
112-
icon: <Icon icon="external-link" alt="Opens in a new tab" />,
113-
}}
114-
/>
112+
/>,
113+
<Icon
114+
key="icon"
115+
icon="external-link"
116+
alt="Opens in a new tab"
117+
/>,
118+
]}
119+
/>
120+
</span>
115121
</Checkbox>
116122

117123
<Checkbox onChange={handleChange}>
118-
{t('commitStep.noAgendas')}
124+
<span>{t('commitStep.noAgendas')}</span>
119125
</Checkbox>
120126
</div>
121127

@@ -137,10 +143,12 @@ export const CommitStep = ({
137143
<GraphicalIcon icon="arrow-right" />
138144
</FormButton>
139145
</div>
146+
140147
<ErrorBoundary>
141148
<ErrorMessage error={error} defaultError={DEFAULT_ERROR} />
142149
</ErrorBoundary>
143150
</div>
151+
144152
<div className="rhs">
145153
<GraphicalIcon icon="mentoring-screen" category="graphics" />
146154
</div>

app/javascript/components/modals/mentor-registration-modal/commit-step/ReputationInfo.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import React from 'react'
44
import { GraphicalIcon } from '../../../common'
55
import { useAppTranslation } from '@/i18n/useAppTranslation'
6+
import { Trans } from 'react-i18next'
67

78
export const ReputationInfo = (): JSX.Element => {
89
const { t } = useAppTranslation(
@@ -14,7 +15,15 @@ export const ReputationInfo = (): JSX.Element => {
1415
<GraphicalIcon icon="reputation" />
1516
<div className="info">
1617
<h3>{t('reputationInfo.reputationAndTestimonials')}</h3>
17-
<p>{t('reputationInfo.gainReputation')}</p>
18+
<p>
19+
{
20+
<Trans
21+
i18nKey="reputationInfo.gainReputation"
22+
ns="components/modals/mentor-registration-modal/commit-step"
23+
components={[<strong />]}
24+
/>
25+
}
26+
</p>
1827
</div>
1928
</div>
2029
</div>

app/javascript/i18n/en/components-modals-mentor-registration-modal-commit-step.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
export default {
33
'reputationInfo.reputationAndTestimonials': 'Reputation & testimonials',
44
'reputationInfo.gainReputation':
5-
"You'll gain <strong>6 reputation</strong> for each successful mentoring session. At the end of every discussion, students are invited to leave you a testimonial.",
5+
"You'll gain <0>6 reputation</0> for each successful mentoring session. At the end of every discussion, students are invited to leave you a testimonial.",
66
}

app/javascript/i18n/en/components-modals-mentor-registration-modal.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ export default {
44
'commitStep.description':
55
"Mentoring on Exercism can be an incredible experience for students and mentors alike. To ensure it remains a positive place for everyone, we ask all mentors to affirm Exercism's values before they mentor their first solution.",
66
'commitStep.youAgreeTo': 'You agree to:',
7-
'commitStep.codeOfConduct': 'Abide by the <a>Code of Conduct <icon/></a>',
7+
'commitStep.codeOfConduct': 'Abide by the <0>Code of Conduct <1/></0>',
88
'commitStep.beKind':
99
"Be patient, empathic and kind to those you're mentoring",
1010
'commitStep.intellectualHumility':
11-
'Demonstrate <a>intellectual humility <icon/></a>',
11+
'Demonstrate <0>intellectual humility <1/></0>',
1212
'commitStep.noAgendas': 'Not use Exercism to promote personal agendas',
1313
'commitStep.back': 'Back',
1414
'commitStep.continue': 'Continue',
1515
'chooseTrackStep.selectTracks': 'Select the tracks you want to mentor',
1616
'chooseTrackStep.allowsUsToShow':
17-
'This allows us to only show you the solutions you want to mentor. <strong>Don’t worry, you can change these selections at anytime.</strong>',
17+
'This allows us to only show you the solutions you want to mentor. <0>Don’t worry, you can change these selections at anytime.</0>',
1818
'stepIndicator.step': 'Step {{num}}: {{label}}',
1919
'closeButton.closeModal': 'Close the modal',
2020
'congratulationsStep.youAreNowMentor': 'You’re now a mentor!',

0 commit comments

Comments
 (0)