diff options
author | Raphael Kabo <mail@raphaelkabo.com> | 2025-05-28 18:01:08 +0100 |
---|---|---|
committer | Raphael Kabo <mail@raphaelkabo.com> | 2025-05-28 18:01:08 +0100 |
commit | a5e2faf58ddd4793a5f7e3e284b023162d69cbb3 (patch) | |
tree | df8dacfd279760f505d4b0f6dcf195a6a44a6a1b /src/lib | |
parent | bc9e983b16d9ac2d27a4458c0a87f9d11aa80c0e (diff) | |
parent | bde9b408342f56833cf0a514488365189083f312 (diff) |
Merge remote-tracking branch 'origin/main' into raphael/add-mailgun
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/config.ts | 27 | ||||
-rw-r--r-- | src/lib/event.ts | 4 | ||||
-rw-r--r-- | src/lib/middleware.ts | 2 |
3 files changed, 19 insertions, 14 deletions
diff --git a/src/lib/config.ts b/src/lib/config.ts index 3fd6eb7..35fc42c 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -3,6 +3,7 @@ import toml from "toml"; import { exitWithError } from "./process.js"; import { Response } from "express"; import { markdownToSanitizedHTML } from "../util/markdown.js"; +import i18next from "i18next"; interface StaticPage { title: string; @@ -115,44 +116,44 @@ export const instanceRules = (): InstanceRule[] => { rules.push( config.general.show_public_event_list ? { - text: "Public events and groups are displayed on the homepage", + text: i18next.t("config.instancerule.showpubliceventlist-true"), icon: "fas fa-eye", } : { - text: "Events and groups can only be accessed by direct link", + text: i18next.t("config.instancerule.showpubliceventlist-false"), icon: "fas fa-eye-slash", }, ); rules.push( config.general.creator_email_addresses?.length ? { - text: "Only specific people can create events and groups", + text: i18next.t("config.instancerule.creatoremail-true"), icon: "fas fa-user-check", } : { - text: "Anyone can create events and groups", + text: i18next.t("config.instancerule.creatoremail-false"), icon: "fas fa-users", }, ); rules.push( config.general.delete_after_days > 0 ? { - text: `Events are automatically deleted ${config.general.delete_after_days} days after they end`, + text: i18next.t("config.instancerule.deleteafterdays-true", { days: config.general.delete_after_days } ), icon: "far fa-calendar-times", } : { - text: "Events are permanent, and are never automatically deleted", + text: i18next.t("config.instancerule.deleteafterdays-false"), icon: "far fa-calendar-check", }, ); rules.push( config.general.is_federated ? { - text: "This instance federates with other instances using ActivityPub", + text: i18next.t("config.instancerule.isfederated-true"), icon: "fas fa-globe", } : { - text: "This instance does not federate with other instances", + text: i18next.t("config.instancerule.isfederated-false"), icon: "fas fa-globe", }, ); @@ -161,13 +162,15 @@ export const instanceRules = (): InstanceRule[] => { export const instanceDescription = (): string => { const config = getConfig(); - const defaultInstanceDescription = - "**{{ siteName }}** is running on Gathio — a simple, federated, privacy-first event hosting platform."; + const defaultInstanceDescription = markdownToSanitizedHTML( + i18next.t("config.defaultinstancedesc", "Welcome to this Gathio instance!") + ); let instanceDescription = defaultInstanceDescription; + let instancedescfile = "./static/instance-description-" + i18next.language + ".md"; try { - if (fs.existsSync("./static/instance-description.md")) { + if (fs.existsSync(instancedescfile)) { const fileBody = fs.readFileSync( - "./static/instance-description.md", + instancedescfile, "utf-8", ); instanceDescription = markdownToSanitizedHTML(fileBody); diff --git a/src/lib/event.ts b/src/lib/event.ts index 334ddf6..bcb7cd9 100644 --- a/src/lib/event.ts +++ b/src/lib/event.ts @@ -1,3 +1,4 @@ +import i18next from "i18next"; import { IEventGroup } from "../models/EventGroup.js"; export interface EventListEvent { @@ -15,7 +16,8 @@ export const bucketEventsByMonth = ( acc: Record<string, any>[], event: EventListEvent, ) => { - const month = event.startMoment.format("MMMM YYYY"); + event.startMoment.locale(i18next.language); + const month = event.startMoment.format(i18next.t("common.year-month-format" )); const matchingBucket = acc.find((bucket) => bucket.title === month); if (!matchingBucket) { acc.push({ diff --git a/src/lib/middleware.ts b/src/lib/middleware.ts index 69fbe4e..be05c3f 100644 --- a/src/lib/middleware.ts +++ b/src/lib/middleware.ts @@ -62,7 +62,7 @@ export const getConfigMiddleware = ( if (process.env.CYPRESS === "true" && req.cookies?.cypressConfigOverride) { console.log("Overriding config with Cypress config"); const override = JSON.parse(req.cookies.cypressConfigOverride); - res.locals.config = deepMerge<GathioConfig>(config, override); + res.locals.config = deepMerge(config, override); return next(); } res.locals.config = config; |