Skip to content

Commit 3174e4c

Browse files
locales betternments
1 parent 26fd876 commit 3174e4c

File tree

10 files changed

+50
-49
lines changed

10 files changed

+50
-49
lines changed

src/client/V2/AppV2.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import TextFeedbackV2 from './components/TextFeedbackV2'
1717
import { CourseRecommendation } from '../../common/types'
1818
import AdminModal from './components/AdminModal'
1919
import LanguageSelector from './components/LanguageSelector'
20+
import { useTranslation } from 'react-i18next'
2021

2122
const desktopDrawerWidth = '33.333vw' // 1/3 of the viewport width
2223
const mobileDrawerWidth = '80vw' // 80% of the viewport width for mobile
@@ -26,7 +27,8 @@ const OneThirdDrawerLayout = () => {
2627
const isMobile = useMediaQuery(theme.breakpoints.down('sm'))
2728
const [open, setOpen] = useState(!isMobile)
2829
const [adminModalOpen, setAdminModalOpen] = useState(false)
29-
const { modalOpen, setModalOpen, finalRecommendedCourses } = useFilterContext()
30+
const { modalOpen, setModalOpen, finalRecommendedCourses } = useFilterContext()
31+
const { t } = useTranslation()
3032
useEffect(() => {
3133
setOpen(!isMobile)
3234
}, [isMobile])
@@ -40,7 +42,9 @@ const OneThirdDrawerLayout = () => {
4042
return (
4143
<Stack direction='column' sx={{width: '100vw', height: '100vh'}}>
4244
<Typography variant='h2' sx={{marginLeft: 'auto', marginRight: 'auto'}}>Apparaatti</Typography>
43-
<Typography sx={{marginLeft: 'auto', marginRight: 'auto'}}>Please log in: <a href="/api/login">here</a></Typography>
45+
<Typography sx={{marginLeft: 'auto', marginRight: 'auto'}}>
46+
{t('v2:loginPrompt')} <a href="/api/login">{t('v2:loginLink')}</a>
47+
</Typography>
4448

4549
</Stack>
4650
)
@@ -81,12 +85,12 @@ const OneThirdDrawerLayout = () => {
8185
<MenuIcon />
8286
</IconButton>
8387
<Typography variant="h6" noWrap sx={{ flexGrow: 1 }}>
84-
Course Finder
88+
{t('v2:appTitle')}
8589
</Typography>
8690
<LanguageSelector />
8791
{user?.isAdmin && (
8892
<Button color="inherit" onClick={() => setAdminModalOpen(true)} sx={{ ml: 2 }}>
89-
ADMIN
93+
{t('v2:adminButton')}
9094
</Button>
9195
)}
9296
</Toolbar>

src/client/V2/FilterRenderer.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { pickVariant, updateVariantToDisplayId } from '../hooks/useQuestions'
33
import FilterAccordion from './FilterAccordion'
44
import { useFilterContext, filterConfigMap } from './filterContext'
55
import Filter from './filters/filter'
6-
import { filterTitles } from './sideBarContent'
76

87
const FilterRenderer = ({ filter }: { filter: any }) => {
98
const filters = useFilterContext()
@@ -16,7 +15,7 @@ const FilterRenderer = ({ filter }: { filter: any }) => {
1615
const setState = config ? config.setState : () => {}
1716
const displayType = config && config.displayType ? config.displayType : 'singlechoice'
1817
const superToggle = config && config.superToggle !== undefined ? config.superToggle : true
19-
const shortName = config ? config.shortName : ''
18+
const shortName = filter.shortName || filter.id
2019

2120
const skipInSideBar = config ? config.hideInFilterSideBar : false
2221
return {...filter, displayType, state, setState, superToggle, shortName, skipInSideBar}
@@ -32,7 +31,7 @@ const FilterRenderer = ({ filter }: { filter: any }) => {
3231
return (
3332
<FilterAccordion
3433
key={filter.id}
35-
title={filterToRender.shortName || filterTitles[filter.id] || filter.id}
34+
title={filterToRender.shortName}
3635
>
3736
<Filter variant={variant} filter={filterToRender} />
3837
</FilterAccordion>

src/client/V2/currentFilterDisplay.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const ActiveFilterCard = ({ filterId }: {filterId: string}) => {
4646
const cfg = filterConfigMap(filterContext).get(filterId)
4747
const hide = cfg?.hideInCurrentFiltersDisplay != undefined ? cfg.hideInCurrentFiltersDisplay : false
4848
const variant = getFilterVariant(filterContext, filterId)
49+
const question = filterContext.filters.find((q: any) => q.id === filterId)
4950

5051
const handleClearFilter = () => {
5152
if (!cfg) return
@@ -65,7 +66,7 @@ const ActiveFilterCard = ({ filterId }: {filterId: string}) => {
6566
return (
6667
<Stack direction="row" alignItems="center" spacing={1}>
6768
<Typography variant="body1">
68-
<strong>{cfg?.shortName}: </strong>
69+
<strong>{question?.shortName || filterId}: </strong>
6970
</Typography>
7071
<Stack direction="row" spacing={1} flexWrap="wrap">
7172
<FilterValueRenderer cfg={cfg} variant={variant}/>

src/client/V2/filterContext.tsx

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ interface FilterContextType {
6868

6969
export const filterConfigMap = (filters: any) => new Map([
7070
['study-field-select', {
71-
shortName: 'Opinto-oikeus',
7271
state: filters.studyField,
7372
setState: filters.setStudyField,
7473
displayType: 'dropdownselect',
@@ -77,83 +76,70 @@ export const filterConfigMap = (filters: any) => new Map([
7776
hideInRecommendationReasons: true
7877
}],
7978
['primary-language', {
80-
shortName: 'Koulukieli',
8179
state: filters.primaryLanguage,
8280
setState: filters.setPrimaryLanguage,
8381
hideInCurrentFiltersDisplay: false,
8482
hideInRecommendationReasons: true
8583
}],
8684
['lang', {
87-
shortName: 'Kurssi',
8885
state: filters.language,
8986
setState: filters.setLanguage,
9087
hideInRecommendationReasons: true
9188
}],
9289
['primary-language-specification', {
93-
shortName: 'Viestintä',
9490
state: filters.primaryLanguageSpecification,
9591
setState: filters.setPrimaryLanguageSpecification,
9692
hideInRecommendationReasons: true
9793
}],
9894
['previusly-done-lang', {
99-
shortName: 'Aikaisemmat opinnot',
10095
state: filters.previouslyDoneLang,
10196
setState: filters.setPreviouslyDoneLang,
10297
superToggle: false,
10398
hideInCurrentFiltersDisplay: true,
10499
hideInRecommendationReasons: true
105100
}],
106101
['replacement', {
107-
shortName: 'Korvaava',
108102
state: filters.replacement,
109103
setState: filters.setReplacement,
110104
superToggle: false
111105
}],
112106
['mentoring', {
113-
shortName: 'Valmentava',
114107
state: filters.mentoring,
115108
setState: filters.setMentoring,
116109
superToggle: false
117110
}],
118111
['finmu', {
119-
shortName: 'Finmu',
120112
state: filters.finmu,
121113
setState: filters.setFinmu,
122114
superToggle: false
123115
}],
124116
['challenge', {
125-
shortName: 'Edistynyt',
126117
state: filters.challenge,
127118
setState: filters.setChallenge,
128119
superToggle: false
129120
}],
130121
['graduation', {
131-
shortName: 'Valmistuville',
132122
state: filters.graduation,
133123
setState: filters.setGraduation,
134124
superToggle: false
135125
}],
136126
['integrated', {
137-
shortName: 'Integroitu',
138127
state: filters.integrated,
139128
setState: filters.setIntegrated,
140129
superToggle: false
141130
}],
142131
['independent', {
143-
shortName: 'Itsenäinen',
144132
state: filters.independent,
145133
setState: filters.setIndependent,
146134
superToggle: false
147135
}],
148136
['study-place', {
149-
shortName: 'Opetusmuoto',
150137
state: filters.studyPlace,
151138
setState: filters.setStudyPlace,
152139
displayType: 'multichoice',
153140
superToggle: true
154141
}],
155142
['study-year', {
156-
shortName: 'Lukuvuosi',
157143
state: filters.studyYear,
158144
setState: filters.setStudyYear,
159145
displayType: 'singlechoice',
@@ -162,14 +148,12 @@ export const filterConfigMap = (filters: any) => new Map([
162148
hideInFilterSideBar: true
163149
}],
164150
['study-period', {
165-
shortName: 'Periodi',
166151
state: filters.studyPeriod,
167152
setState: filters.setStudyPeriod,
168153
displayType: 'multichoice',
169154
superToggle: false
170155
}],
171156
['mooc', {
172-
shortName: 'MOOC',
173157
state: filters.mooc,
174158
setState: filters.setMooc,
175159
superToggle: true
@@ -198,12 +182,11 @@ export const getCoordinateDisplayName = (coordinateKey: string, filterContext: a
198182
const filterId = coordinateKeyToFilterId[coordinateKey]
199183
if (!filterId) return coordinateKey
200184

201-
const filterConfig = filterConfigMap(filterContext)
202-
const filterCfg = filterConfig.get(filterId)
185+
const question = filterContext.filters.find((q: any) => q.id === filterId)
203186

204-
if (!filterCfg?.shortName) return coordinateKey
187+
if (!question?.shortName) return coordinateKey
205188

206-
return t(`filterShortName:${filterCfg.shortName}`)
189+
return question.shortName
207190
}
208191

209192

src/client/V2/sideBarContent.tsx

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,12 @@ import { useTranslation } from 'react-i18next'
44
import ActionButtonV2 from './components/ActionButtonV2'
55
import { Box } from '@mui/material'
66

7-
export const filterTitles: { [key: string]: string } = {
8-
'study-field-select': 'Study Field',
9-
'primary-language': 'Primary Language',
10-
lang: 'Language of Study',
11-
'primary-language-specification': 'Language Skills',
12-
'previusly-done-lang': 'Previous Language Studies',
13-
replacement: 'Replacement Courses',
14-
mentoring: 'Mentoring',
15-
finmu: 'Finmu',
16-
challenge: 'Extra Challenge',
17-
graduation: 'Close to Graduation',
18-
'study-place': 'Study Method',
19-
'study-period': 'Study Period',
20-
integrated: 'Integrated Studies',
21-
independent: 'Independent Study',
22-
}
23-
247
const SidebarContent = () => {
258
const { filters, isLoading, setModalOpen } = useFilterContext()
269
const { t } = useTranslation()
2710

2811
if (isLoading) {
29-
return <p>Loading filters...</p>
12+
return <p>{t('v2:loadingFilters')}</p>
3013
}
3114

3215
const filtersToShow = filters.filter(

src/client/hooks/useQuestions.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ const useQuestions = () => {
133133
mandatory: true,
134134
effects: 'org',
135135
id: 'study-field-select',
136+
shortName: t('filterShortName:Opinto-oikeus'),
136137
type: 'studyphase',
137138
variants: [
138139
{
@@ -146,6 +147,7 @@ const useQuestions = () => {
146147
mandatory: true,
147148
effects: 'lang',
148149
id: 'primary-language',
150+
shortName: t('filterShortName:Koulukieli'),
149151
type: 'primary-language',
150152
explanation: t('form:primaryLanguageExplanation'),
151153
variants: [
@@ -165,6 +167,7 @@ const useQuestions = () => {
165167
mandatory: true,
166168
effects: 'lang',
167169
id: 'lang',
170+
shortName: t('filterShortName:Kurssi'),
168171
type: 'language',
169172
explanation: t('form:searchedLanguageExplanation'),
170173
variants: [
@@ -185,6 +188,7 @@ const useQuestions = () => {
185188
mandatory: true,
186189
effects: 'lang',
187190
id: 'primary-language-specification',
191+
shortName: t('filterShortName:Viestintä'),
188192
isSubQuestionForQuestionId: 'lang',
189193
type: 'primary-language-specification',
190194

@@ -205,6 +209,7 @@ const useQuestions = () => {
205209
effects: 'none',
206210
mandatory: false,
207211
id: 'previusly-done-lang',
212+
shortName: t('filterShortName:Aikaisemmat opinnot'),
208213
type: 'previusly-done-lang',
209214
explanation: t('form:previoslyDoneLangExplanation'),
210215
extraInfo: t('question:checkInstructionsCrediting'),
@@ -221,6 +226,7 @@ const useQuestions = () => {
221226
mandatory: false,
222227
effects: 'date',
223228
id: 'study-year',
229+
shortName: t('filterShortName:Lukuvuosi'),
224230
type: 'period-date',
225231
variants: [
226232
{
@@ -239,6 +245,7 @@ const useQuestions = () => {
239245
mandatory: false,
240246
effects: 'date',
241247
id: 'study-period',
248+
shortName: t('filterShortName:Periodi'),
242249
type: 'period-date',
243250
// explanation: 'Mistä periodista haluat kursseja?',
244251
variants: [
@@ -266,6 +273,7 @@ const useQuestions = () => {
266273
mandatory: false,
267274
effects: 'none',
268275
id: 'replacement',
276+
shortName: t('filterShortName:Korvaava'),
269277
type: 'multi',
270278
variants: [
271279
{
@@ -305,6 +313,7 @@ const useQuestions = () => {
305313
number: '',
306314
mandatory: false,
307315
id: 'mentoring',
316+
shortName: t('filterShortName:Valmentava'),
308317
effects: 'mentoring',
309318
type: 'multi',
310319

@@ -336,6 +345,7 @@ const useQuestions = () => {
336345
number: '',
337346
mandatory: false,
338347
id: 'finmu',
348+
shortName: t('filterShortName:Finmu'),
339349
effects: 'finmu',
340350
type: 'multi',
341351
variants: [
@@ -357,6 +367,7 @@ const useQuestions = () => {
357367
number: '',
358368
mandatory: false,
359369
id: 'challenge',
370+
shortName: t('filterShortName:Edistynyt'),
360371
effects: 'challenge',
361372
type: 'multi',
362373
variants: [
@@ -404,6 +415,7 @@ const useQuestions = () => {
404415
number: '',
405416
mandatory: false,
406417
id: 'graduation',
418+
shortName: t('filterShortName:Valmistuville'),
407419
type: 'multi',
408420

409421
effects: 'graduation',
@@ -419,6 +431,7 @@ const useQuestions = () => {
419431
number: '',
420432
mandatory: false,
421433
id: 'study-place',
434+
shortName: t('filterShortName:Opetusmuoto'),
422435
effects: 'studyPlace',
423436
type: 'study-place',
424437
variants: [
@@ -439,6 +452,7 @@ const useQuestions = () => {
439452
number: '',
440453
mandatory: false,
441454
id: 'integrated',
455+
shortName: t('filterShortName:Integroitu'),
442456
effects: 'integrated',
443457
type: 'multi',
444458
variants: [
@@ -464,6 +478,7 @@ const useQuestions = () => {
464478
number: '',
465479
mandatory: false,
466480
id: 'independent',
481+
shortName: t('filterShortName:Itsenäinen'),
467482
effects: 'independent',
468483
type: 'multi',
469484
variants: [

src/client/locales/en.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,12 @@ export default {
9090
'title': 'No courses found',
9191
'description': 'Try changing your selections to see courses.',
9292
'resetButton': 'Reset'
93-
}
93+
},
94+
'appTitle': 'Course Finder',
95+
'adminButton': 'ADMIN',
96+
'loginPrompt': 'Please log in:',
97+
'loginLink': 'here',
98+
'loadingFilters': 'Loading filters...'
9499
},
95100
'course': {
96101
'show': 'Show',

src/client/locales/fi.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,12 @@ export default {
9090
'title': 'Kursseja ei löytynyt',
9191
'description': 'Yritä muuttaa valintojasi nähdäksesi kursseja.',
9292
'resetButton': 'Nollaa'
93-
}
93+
},
94+
'appTitle': 'Kurssihakukone',
95+
'adminButton': 'ADMIN',
96+
'loginPrompt': 'Ole hyvä ja kirjaudu sisään:',
97+
'loginLink': 'täältä',
98+
'loadingFilters': 'Ladataan suodattimia...'
9499
},
95100
'course': {
96101
'show': 'Näytä',

0 commit comments

Comments
 (0)