mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-03 21:19:01 +01:00 
			
		
		
		
	server: Translate weekday and month names
This commit is contained in:
		
							parent
							
								
									77550f3087
								
							
						
					
					
						commit
						af67362ad6
					
				@ -9,14 +9,20 @@ import searchService from "../services/search/services/search.js";
 | 
				
			|||||||
import SearchContext from "../services/search/search_context.js";
 | 
					import SearchContext from "../services/search/search_context.js";
 | 
				
			||||||
import hoistedNoteService from "./hoisted_note.js";
 | 
					import hoistedNoteService from "./hoisted_note.js";
 | 
				
			||||||
import BNote from "../becca/entities/bnote.js";
 | 
					import BNote from "../becca/entities/bnote.js";
 | 
				
			||||||
 | 
					import { t } from "i18next";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const CALENDAR_ROOT_LABEL = 'calendarRoot';
 | 
					const CALENDAR_ROOT_LABEL = 'calendarRoot';
 | 
				
			||||||
const YEAR_LABEL = 'yearNote';
 | 
					const YEAR_LABEL = 'yearNote';
 | 
				
			||||||
const MONTH_LABEL = 'monthNote';
 | 
					const MONTH_LABEL = 'monthNote';
 | 
				
			||||||
const DATE_LABEL = 'dateNote';
 | 
					const DATE_LABEL = 'dateNote';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const DAYS = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
 | 
					const WEEKDAY_TRANSLATION_IDS = [
 | 
				
			||||||
const MONTHS = ['January','February','March','April','May','June','July','August','September','October','November','December'];
 | 
					    "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";
 | 
					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) {
 | 
					function getMonthNoteTitle(rootNote: BNote, monthNumber: string, dateObj: Date) {
 | 
				
			||||||
    const pattern = rootNote.getOwnedLabelValue("monthPattern") || "{monthNumberPadded} - {month}";
 | 
					    const pattern = rootNote.getOwnedLabelValue("monthPattern") || "{monthNumberPadded} - {month}";
 | 
				
			||||||
    const monthName = MONTHS[dateObj.getMonth()];
 | 
					    const monthName = t(MONTH_TRANSLATION_IDS[dateObj.getMonth()]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return pattern
 | 
					    return pattern
 | 
				
			||||||
        .replace(/{shortMonth3}/g, monthName.slice(0,3))
 | 
					        .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) {
 | 
					function getDayNoteTitle(rootNote: BNote, dayNumber: string, dateObj: Date) {
 | 
				
			||||||
    const pattern = rootNote.getOwnedLabelValue("datePattern") || "{dayInMonthPadded} - {weekDay}";
 | 
					    const pattern = rootNote.getOwnedLabelValue("datePattern") || "{dayInMonthPadded} - {weekDay}";
 | 
				
			||||||
    const weekDay = DAYS[dateObj.getDay()];
 | 
					    const weekDay = t(WEEKDAY_TRANSLATION_IDS[dateObj.getDay()]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return pattern
 | 
					    return pattern
 | 
				
			||||||
        .replace(/{ordinal}/g, ordinal(parseInt(dayNumber)))
 | 
					        .replace(/{ordinal}/g, ordinal(parseInt(dayNumber)))
 | 
				
			||||||
 | 
				
			|||||||
@ -157,5 +157,28 @@
 | 
				
			|||||||
    "clipped-from": "This note was originally clipped from {{- url}}",
 | 
					    "clipped-from": "This note was originally clipped from {{- url}}",
 | 
				
			||||||
    "child-notes": "Child notes:",
 | 
					    "child-notes": "Child notes:",
 | 
				
			||||||
    "no-content": "This note has no content."
 | 
					    "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"
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -157,5 +157,28 @@
 | 
				
			|||||||
    "clipped-from": "Această notiță a fost decupată inițial de pe {{- url}}",
 | 
					    "clipped-from": "Această notiță a fost decupată inițial de pe {{- url}}",
 | 
				
			||||||
    "no-content": "Această notiță nu are conținut.",
 | 
					    "no-content": "Această notiță nu are conținut.",
 | 
				
			||||||
    "parent": "părinte:"
 | 
					    "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"
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user