Skip to content

Commit 26fd876

Browse files
locales improvements
1 parent 5605718 commit 26fd876

File tree

6 files changed

+111
-8
lines changed

6 files changed

+111
-8
lines changed

src/client/V2/AppV2.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import CurrentFilterDisplay from './currentFilterDisplay'
1616
import TextFeedbackV2 from './components/TextFeedbackV2'
1717
import { CourseRecommendation } from '../../common/types'
1818
import AdminModal from './components/AdminModal'
19+
import LanguageSelector from './components/LanguageSelector'
1920

2021
const desktopDrawerWidth = '33.333vw' // 1/3 of the viewport width
2122
const mobileDrawerWidth = '80vw' // 80% of the viewport width for mobile
@@ -82,8 +83,9 @@ const OneThirdDrawerLayout = () => {
8283
<Typography variant="h6" noWrap sx={{ flexGrow: 1 }}>
8384
Course Finder
8485
</Typography>
86+
<LanguageSelector />
8587
{user?.isAdmin && (
86-
<Button color="inherit" onClick={() => setAdminModalOpen(true)}>
88+
<Button color="inherit" onClick={() => setAdminModalOpen(true)} sx={{ ml: 2 }}>
8789
ADMIN
8890
</Button>
8991
)}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { Select, MenuItem, SelectChangeEvent } from '@mui/material'
2+
import { useContext } from 'react'
3+
import { LanguageContext } from '../../contexts/languageContext'
4+
5+
const LanguageSelector = () => {
6+
const { language, setAppLanguage } = useContext(LanguageContext)
7+
8+
const handleChange = (event: SelectChangeEvent) => {
9+
setAppLanguage(event.target.value)
10+
}
11+
12+
return (
13+
<Select
14+
value={language}
15+
onChange={handleChange}
16+
size="small"
17+
sx={{
18+
color: 'inherit',
19+
'& .MuiOutlinedInput-notchedOutline': {
20+
borderColor: 'rgba(0, 0, 0, 0.23)',
21+
},
22+
'&:hover .MuiOutlinedInput-notchedOutline': {
23+
borderColor: 'rgba(0, 0, 0, 0.87)',
24+
},
25+
'&.Mui-focused .MuiOutlinedInput-notchedOutline': {
26+
borderColor: 'primary.main',
27+
},
28+
minWidth: 80,
29+
}}
30+
>
31+
<MenuItem value="fi">Suomi</MenuItem>
32+
<MenuItem value="en">English</MenuItem>
33+
<MenuItem value="sv">Svenska</MenuItem>
34+
</Select>
35+
)
36+
}
37+
38+
export default LanguageSelector

src/client/V2/components/NoRecommendationsInfo.tsx

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,40 @@
1-
import { Box, Typography, Paper } from '@mui/material'
1+
import { Box, Typography, Paper, Button } from '@mui/material'
2+
import { useFilterContext } from '../filterContext'
3+
import { useTranslation } from 'react-i18next'
24

35
const NoRecommendationsInfo = () => {
6+
const { t } = useTranslation()
7+
const {
8+
setPreviouslyDoneLang,
9+
setReplacement,
10+
setMentoring,
11+
setFinmu,
12+
setChallenge,
13+
setGraduation,
14+
setStudyPlace,
15+
setStudyPeriod,
16+
setIntegrated,
17+
setIndependent,
18+
setMooc,
19+
setStrictFilters,
20+
} = useFilterContext()
21+
22+
const handleReset = () => {
23+
// Reset all non-mandatory filters to their default values
24+
setPreviouslyDoneLang('')
25+
setReplacement('')
26+
setMentoring('')
27+
setFinmu('')
28+
setChallenge('')
29+
setGraduation('')
30+
setStudyPlace([])
31+
setStudyPeriod([])
32+
setIntegrated('')
33+
setIndependent('')
34+
setMooc('')
35+
setStrictFilters([])
36+
}
37+
438
return (
539
<Paper
640
elevation={2}
@@ -13,11 +47,25 @@ const NoRecommendationsInfo = () => {
1347
>
1448
<Box>
1549
<Typography variant="h6" component="h2" gutterBottom>
16-
Kursseja ei löytynyt
50+
{t('v2:noRecommendations.title')}
1751
</Typography>
18-
<Typography variant="body1" color="textSecondary">
19-
Yritä muuttaa valintojasi nähdäksesi kursseja.
52+
<Typography variant="body1" color="textSecondary" sx={{ mb: 3 }}>
53+
{t('v2:noRecommendations.description')}
2054
</Typography>
55+
<Button
56+
variant="outlined"
57+
onClick={handleReset}
58+
sx={{
59+
borderColor: '#90caf9',
60+
color: 'black',
61+
'&:hover': {
62+
backgroundColor: '#2196f3',
63+
color: 'white',
64+
},
65+
}}
66+
>
67+
{t('v2:noRecommendations.resetButton')}
68+
</Button>
2169
</Box>
2270
</Paper>
2371
)

src/client/locales/en.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,12 @@ export default {
8585
},
8686
'retakeQuestions': 'Answer starting questions',
8787
'done': 'Done',
88-
'welcomeText': 'First, answer a few initial questions. You can modify these later.'
88+
'welcomeText': 'First, answer a few initial questions. You can modify these later.',
89+
'noRecommendations': {
90+
'title': 'No courses found',
91+
'description': 'Try changing your selections to see courses.',
92+
'resetButton': 'Reset'
93+
}
8994
},
9095
'course': {
9196
'show': 'Show',

src/client/locales/fi.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,12 @@ export default {
8585
},
8686
'retakeQuestions': 'Vastaa alkukysymyksiin',
8787
'done': 'Valmis',
88-
'welcomeText': 'Vastaa ensin muutamaan alkukysymykseen. Voit muokata näitä myöhemmin.'
88+
'welcomeText': 'Vastaa ensin muutamaan alkukysymykseen. Voit muokata näitä myöhemmin.',
89+
'noRecommendations': {
90+
'title': 'Kursseja ei löytynyt',
91+
'description': 'Yritä muuttaa valintojasi nähdäksesi kursseja.',
92+
'resetButton': 'Nollaa'
93+
}
8994
},
9095
'course': {
9196
'show': 'Näytä',

src/client/locales/sv.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,12 @@ export default {
8585
},
8686
'retakeQuestions': 'Svara på startfrågorna',
8787
'done': 'Klar',
88-
'welcomeText': 'Svara först på några inledande frågor. Du kan ändra dessa senare.'
88+
'welcomeText': 'Svara först på några inledande frågor. Du kan ändra dessa senare.',
89+
'noRecommendations': {
90+
'title': 'Inga kurser hittades',
91+
'description': 'Försök ändra dina val för att se kurser.',
92+
'resetButton': 'Återställ'
93+
}
8994
},
9095
'course': {
9196
'show': 'Visa',

0 commit comments

Comments
 (0)