Skip to content

Build your personal knowledge base with Trilium Notes

server: Translate weekday and month names

Elian Doranaf67362ad65e
diff --git a/src/services/date_notes.ts b/src/services/date_notes.ts
index 465757328a..3f355f4291 100644
--- a/src/services/date_notes.ts
+++ b/src/services/date_notes.ts
@@ -9,14 +9,20 @@ import searchService from "../services/search/services/search.js";
import SearchContext from "../services/search/search_context.js";
import hoistedNoteService from "./hoisted_note.js";
import BNote from "../becca/entities/bnote.js";
+import { t } from "i18next";
const CALENDAR_ROOT_LABEL = 'calendarRoot';
const YEAR_LABEL = 'yearNote';
const MONTH_LABEL = 'monthNote';
const DATE_LABEL = 'dateNote';
-const DAYS = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
-const MONTHS = ['January','February','March','April','May','June','July','August','September','October','November','December'];
+const WEEKDAY_TRANSLATION_IDS = [
+ "weekdays.sunday", "weekdays.monday", "weekdays.tuesday", "weekdays.wednesday", "weekdays.thursday", "weekdays.friday", "weekdays.saturday", "weekdays.sunday"
+];
+
+const MONTH_TRANSLATION_IDS = [
+ "months.january", "months.february", "months.march", "months.april", "months.may", "months.june", "months.july", "months.august", "months.september", "months.october", "months.november", "months.december"
+];
type StartOfWeek = "monday" | "sunday";
@@ -92,7 +98,7 @@ function getYearNote(dateStr: string, _rootNote: BNote | null = null): BNote {
function getMonthNoteTitle(rootNote: BNote, monthNumber: string, dateObj: Date) {
const pattern = rootNote.getOwnedLabelValue("monthPattern") || "{monthNumberPadded} - {month}";
- const monthName = MONTHS[dateObj.getMonth()];
+ const monthName = t(MONTH_TRANSLATION_IDS[dateObj.getMonth()]);
return pattern
.replace(/{shortMonth3}/g, monthName.slice(0,3))
@@ -138,7 +144,7 @@ function getMonthNote(dateStr: string, _rootNote: BNote | null = null): BNote {
function getDayNoteTitle(rootNote: BNote, dayNumber: string, dateObj: Date) {
const pattern = rootNote.getOwnedLabelValue("datePattern") || "{dayInMonthPadded} - {weekDay}";
- const weekDay = DAYS[dateObj.getDay()];
+ const weekDay = t(WEEKDAY_TRANSLATION_IDS[dateObj.getDay()]);
return pattern
.replace(/{ordinal}/g, ordinal(parseInt(dayNumber)))
diff --git a/translations/en/server.json b/translations/en/server.json
index 3d8a46e55c..68de4c6f05 100644
--- a/translations/en/server.json
+++ b/translations/en/server.json
@@ -157,5 +157,28 @@
"clipped-from": "This note was originally clipped from {{- url}}",
"child-notes": "Child notes:",
"no-content": "This note has no content."
+ },
+ "weekdays": {
+ "monday": "Monday",
+ "tuesday": "Tuesday",
+ "wednesday": "Wednesday",
+ "thursday": "Thursday",
+ "friday": "Friday",
+ "saturday": "Saturday",
+ "sunday": "Sunday"
+ },
+ "months": {
+ "january": "January",
+ "february": "February",
+ "march": "March",
+ "april": "April",
+ "may": "May",
+ "june": "June",
+ "july": "July",
+ "august": "August",
+ "september": "September",
+ "october": "October",
+ "november": "November",
+ "december": "December"
}
}
diff --git a/translations/ro/server.json b/translations/ro/server.json
index b71a9b34dc..053823a57b 100644
--- a/translations/ro/server.json
+++ b/translations/ro/server.json
@@ -157,5 +157,28 @@
"clipped-from": "Această notiță a fost decupată inițial de pe {{- url}}",
"no-content": "Această notiță nu are conținut.",
"parent": "părinte:"
+ },
+ "weekdays": {
+ "monday": "Luni",
+ "tuesday": "Marți",
+ "wednesday": "Miercuri",
+ "thursday": "Joi",
+ "friday": "Vineri",
+ "saturday": "Sâmbătă",
+ "sunday": "Duminică"
+ },
+ "months": {
+ "january": "Ianuarie",
+ "february": "Februarie",
+ "march": "Martie",
+ "april": "Aprilie",
+ "may": "Mai",
+ "june": "Iunie",
+ "july": "Iulie",
+ "august": "August",
+ "september": "Septembrie",
+ "october": "Octombrie",
+ "november": "Noiembrie",
+ "december": "Decembrie"
}
}