From 645ef9fe9403ac8e2c0c0209a2445d8ca68a90f2 Mon Sep 17 00:00:00 2001 From: axelbjo Date: Thu, 23 May 2024 15:24:48 +0200 Subject: [PATCH] fix(KUI-1332): updated labels for bread crumbs --- i18n/messages.en.js | 5 +++++ i18n/messages.se.js | 5 +++++ server/utils/breadcrumbUtil.js | 34 ++++++++++++++++++++-------------- 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/i18n/messages.en.js b/i18n/messages.en.js index 70eda4af..050f2188 100644 --- a/i18n/messages.en.js +++ b/i18n/messages.en.js @@ -272,4 +272,9 @@ module.exports = { coursePresentationLabels: { coursePresentation: 'Course presentation', }, + breadCrumbs: { + student: 'Student web', + studies: 'Studies', + directory: 'Course and programme directory', + }, } diff --git a/i18n/messages.se.js b/i18n/messages.se.js index 89859231..fb51fbcb 100644 --- a/i18n/messages.se.js +++ b/i18n/messages.se.js @@ -242,4 +242,9 @@ module.exports = { coursePresentationLabels: { coursePresentation: 'Presentation av kursen', }, + breadCrumbs: { + student: 'Studentwebb', + studies: 'Studier', + directory: 'Kurs- och programkatalogen', + }, } diff --git a/server/utils/breadcrumbUtil.js b/server/utils/breadcrumbUtil.js index 4369a5ae..9d9ae2ee 100644 --- a/server/utils/breadcrumbUtil.js +++ b/server/utils/breadcrumbUtil.js @@ -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) { @@ -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)) }