Files
website/layers/cv/app/composables/useCvLang.ts
T
2026-10-02 17:32:02 +02:00

54 lines
1.4 KiB
TypeScript

export type CvLang = 'en' | 'de'
const TEXT = {
en: {
experience: 'Experience',
education: 'Education',
today: 'today',
grade: 'Grade',
year: ['year', 'years'],
month: ['month', 'months'],
loadError: 'The CV could not be loaded',
empty: 'Nothing here yet.',
photo: 'Profile picture',
savePdf: 'Save as PDF',
types: {
'Part-time': 'Part-time',
'Student': 'Student',
'Pupil': 'Pupil',
'Working Student': 'Working Student',
'Volunteer': 'Volunteer'
}
},
de: {
experience: 'Erfahrung',
education: 'Ausbildung',
today: 'heute',
grade: 'Note',
year: ['Jahr', 'Jahre'],
month: ['Monat', 'Monate'],
loadError: 'Der Lebenslauf konnte nicht geladen werden',
empty: 'Noch nichts hier.',
photo: 'Profilbild',
savePdf: 'Als PDF speichern',
types: {
'Part-time': 'Teilzeit',
'Student': 'Studium',
'Pupil': 'Schule',
'Working Student': 'Werkstudent',
'Volunteer': 'Freiwilligendienst'
}
}
} satisfies Record<CvLang, unknown>
export type CvText = typeof TEXT.en
/** The CV's language, remembered in a cookie so the server renders the same one */
export function useCvLang() {
const lang = useCookie<CvLang>('cv-lang', { default: () => 'de', maxAge: 60 * 60 * 24 * 365, sameSite: 'lax' })
return {
lang,
t: computed<CvText>(() => TEXT[lang.value] ?? TEXT.de)
}
}