mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-27 06:52:35 -04:00
[trans][calendar][bug] fix missing fallbacks for calendar bot
This commit is contained in:
parent
4d6f7afa8b
commit
bfc186dee0
@ -8,6 +8,7 @@ import { Day } from '../../src/calendar/helpers';
|
||||
// TODO caching? // import { caches } from "../../src/cache";
|
||||
|
||||
const translations = loadSuml('translations');
|
||||
const fallbackTranslations = loadSuml('../_base/translations');
|
||||
|
||||
const renderEvents = (yearEvents, res) => {
|
||||
const events = [];
|
||||
@ -16,7 +17,7 @@ const renderEvents = (yearEvents, res) => {
|
||||
if (!yearEvents.hasOwnProperty(year)) { continue; }
|
||||
for (let event of yearEvents[year]) {
|
||||
if (!event) { continue; }
|
||||
const ics = event.toIcs(year, translations, clearLinkedText, i);
|
||||
const ics = event.toIcs(year, translations, fallbackTranslations, clearLinkedText, i);
|
||||
if (ics !== null) {
|
||||
events.push(ics);
|
||||
}
|
||||
@ -43,7 +44,7 @@ const renderEvents = (yearEvents, res) => {
|
||||
}
|
||||
|
||||
const getEventName = (name) => {
|
||||
name = translations.calendar.events[name] || name;
|
||||
name = translations.calendar.events[name] || fallbackTranslations.calendar.events[name] || name;
|
||||
name = name.replace(/{.*?=(.*?)}/g, '$1')
|
||||
return name;
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ module.exports.Event = class {
|
||||
return uuid5(`${process.env.BASE_URL}/calendar/event/${this.name}`, uuid5.URL);
|
||||
}
|
||||
|
||||
toIcs(year, translations, clearLinkedText, sequence = 1) {
|
||||
toIcs(year, translations, fallbackTranslations, clearLinkedText, sequence = 1) {
|
||||
const days = this.getDays(year);
|
||||
if (!days.length) {
|
||||
return null;
|
||||
@ -128,6 +128,8 @@ module.exports.Event = class {
|
||||
let [name, param] = this.name.split('$');
|
||||
if (translations.calendar.events[name] !== undefined) {
|
||||
name = translations.calendar.events[name];
|
||||
} else if (fallbackTranslations.calendar.events[name] !== undefined) {
|
||||
name = fallbackTranslations.calendar.events[name];
|
||||
}
|
||||
if (param) {
|
||||
name = name.replace(/%param%/g, param);
|
||||
|
Loading…
x
Reference in New Issue
Block a user