Skip to content

Commit

Permalink
fix(KUI-1332): updated labels for bread crumbs
Browse files Browse the repository at this point in the history
  • Loading branch information
axelbjo committed May 24, 2024
1 parent 28a9392 commit 645ef9f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
5 changes: 5 additions & 0 deletions i18n/messages.en.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,4 +272,9 @@ module.exports = {
coursePresentationLabels: {
coursePresentation: 'Course presentation',
},
breadCrumbs: {
student: 'Student web',
studies: 'Studies',
directory: 'Course and programme directory',
},
}
5 changes: 5 additions & 0 deletions i18n/messages.se.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,9 @@ module.exports = {
coursePresentationLabels: {
coursePresentation: 'Presentation av kursen',
},
breadCrumbs: {
student: 'Studentwebb',
studies: 'Studier',
directory: 'Kurs- och programkatalogen',
},
}
34 changes: 20 additions & 14 deletions server/utils/breadcrumbUtil.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
// Logic is based on old Breadcrumb component in kth-reactstrap: https://github.com/KTH/kth-reactstrap/blob/master/src/components/utbildningsinfo/Breadcrumbs.js
// Be aware that this entire file is replicated in multiple apps, so changes here should probably be synced to the other apps.
// See https://confluence.sys.kth.se/confluence/x/6wYJDQ for more information.
const baseItems = {
university: {
en: { url: '/en', label: 'KTH' },
sv: { url: '/', label: 'KTH' },
},
student: {
en: { url: '/en/student', label: 'Student at KTH' },
sv: { url: '/student', label: 'Student på KTH' },
},
directory: {
en: { url: '/student/kurser/kurser-inom-program?l=en', label: 'Course and programme directory' },
sv: { url: '/student/kurser/kurser-inom-program', label: 'Kurs- och programkatalogen' },
},

const i18n = require('../../i18n')
const baseItems = language => {
const langIndex = language === 'en' ? 0 : 1
const { breadCrumbs } = i18n.messages[langIndex]
return {
student: {
url: `${language === 'en' ? '/en' : ''}/student`,
label: breadCrumbs.student,
},
studies: {
url: `${language === 'en' ? '/en' : ''}/studier`,
label: breadCrumbs.studies,
},
directory: {
url: `/student/kurser/kurser-inom-program${language === 'en' ? '?l=en' : ''}`,
label: breadCrumbs.directory,
},
}
}

function createAboutCourseItem(language, courseCode) {
Expand All @@ -25,7 +31,7 @@ function createAboutCourseItem(language, courseCode) {
}

function createBreadcrumbs(language, courseCode) {
const items = [baseItems.university[language], baseItems.student[language], baseItems.directory[language]]
const items = [baseItems(language).student, baseItems(language).studies, baseItems(language).directory]
if (courseCode) {
items.push(createAboutCourseItem(language, courseCode))
}
Expand Down

0 comments on commit 645ef9f

Please sign in to comment.