mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-28 15:31:11 -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";
|
// TODO caching? // import { caches } from "../../src/cache";
|
||||||
|
|
||||||
const translations = loadSuml('translations');
|
const translations = loadSuml('translations');
|
||||||
|
const fallbackTranslations = loadSuml('../_base/translations');
|
||||||
|
|
||||||
const renderEvents = (yearEvents, res) => {
|
const renderEvents = (yearEvents, res) => {
|
||||||
const events = [];
|
const events = [];
|
||||||
@ -16,7 +17,7 @@ const renderEvents = (yearEvents, res) => {
|
|||||||
if (!yearEvents.hasOwnProperty(year)) { continue; }
|
if (!yearEvents.hasOwnProperty(year)) { continue; }
|
||||||
for (let event of yearEvents[year]) {
|
for (let event of yearEvents[year]) {
|
||||||
if (!event) { continue; }
|
if (!event) { continue; }
|
||||||
const ics = event.toIcs(year, translations, clearLinkedText, i);
|
const ics = event.toIcs(year, translations, fallbackTranslations, clearLinkedText, i);
|
||||||
if (ics !== null) {
|
if (ics !== null) {
|
||||||
events.push(ics);
|
events.push(ics);
|
||||||
}
|
}
|
||||||
@ -43,7 +44,7 @@ const renderEvents = (yearEvents, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getEventName = (name) => {
|
const getEventName = (name) => {
|
||||||
name = translations.calendar.events[name] || name;
|
name = translations.calendar.events[name] || fallbackTranslations.calendar.events[name] || name;
|
||||||
name = name.replace(/{.*?=(.*?)}/g, '$1')
|
name = name.replace(/{.*?=(.*?)}/g, '$1')
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ module.exports.Event = class {
|
|||||||
return uuid5(`${process.env.BASE_URL}/calendar/event/${this.name}`, uuid5.URL);
|
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);
|
const days = this.getDays(year);
|
||||||
if (!days.length) {
|
if (!days.length) {
|
||||||
return null;
|
return null;
|
||||||
@ -128,6 +128,8 @@ module.exports.Event = class {
|
|||||||
let [name, param] = this.name.split('$');
|
let [name, param] = this.name.split('$');
|
||||||
if (translations.calendar.events[name] !== undefined) {
|
if (translations.calendar.events[name] !== undefined) {
|
||||||
name = translations.calendar.events[name];
|
name = translations.calendar.events[name];
|
||||||
|
} else if (fallbackTranslations.calendar.events[name] !== undefined) {
|
||||||
|
name = fallbackTranslations.calendar.events[name];
|
||||||
}
|
}
|
||||||
if (param) {
|
if (param) {
|
||||||
name = name.replace(/%param%/g, param);
|
name = name.replace(/%param%/g, param);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user