Commit f9f73fac authored by Sandro Lutz's avatar Sandro Lutz
Browse files

Fix translation issue with events (fixes #37)

parent 76ee384b
......@@ -163,8 +163,9 @@ export class EventListController extends PaginationController {
return items.map(event => {
const otherLanguage = currentLanguage() === 'en' ? 'de' : 'en';
const newEvent = Object.assign({}, event);
newEvent.title = newEvent[`title_${currentLanguage()}`] || newEvent[`title_${otherLanguage}`];
newEvent.description =
newEvent.getTitle = () =>
newEvent[`title_${currentLanguage()}`] || newEvent[`title_${otherLanguage}`];
newEvent.getDescription = () =>
newEvent[`description_${currentLanguage()}`] || newEvent[`description_${otherLanguage}`];
return new Event(newEvent);
});
......@@ -291,8 +292,8 @@ export class EventController {
if (!event.show_website) {
throw new Error('Event not found');
}
event.title = event[`title_${currentLanguage()}`] || event[`title_${otherLanguage}`];
event.description =
event.getTitle = () => event[`title_${currentLanguage()}`] || event[`title_${otherLanguage}`];
event.getDescription = () =>
event[`description_${currentLanguage()}`] || event[`description_${otherLanguage}`];
this._selectedEvent = new Event(event);
return this._selectedEvent;
......
......@@ -164,7 +164,7 @@ export default class EventDetails {
eventSignupForm = m('div', i18n('events.registration_starts_at', { time: registerStart }));
}
return m('div.event-details', [
m('h1', event.title),
m('h1', event.getTitle()),
m('div', event.time_start),
m(
'div',
......@@ -172,7 +172,7 @@ export default class EventDetails {
? i18n('events.no_registration')
: i18n('events.%n_spots_available', event.spots - event.signup_count)
),
m('p', m.trust(marked(event.description))),
m('p', m.trust(marked(event.getDescription()))),
eventSignupForm,
]);
}
......
......@@ -22,7 +22,7 @@ function renderEventListItem(event, className = '') {
m.route.set(`/${currentLanguage()}/events/${event._id}`);
},
},
[m('h2', event.title), m('span', event.time_start), m('span', event.price)]
[m('h2', event.getTitle()), m('span', event.time_start), m('span', event.price)]
);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment