Add uppercase to Calendar locale

I’ve recently changed my calendar locale from English to Spanish (so it sets the locale for things like daily notes, any dataview query and so on)

But doing so i’ve noted it doesn’t capitalize the words unlike the English locale (instead of “Thursday, January, or Jan.” it outputs "jueves, enero, or ene.,) and that really bothers me

Things I have tried

Given the locale its from moment.js i made a little script that uses the “moment.updateLocale” function to capitalize months and weekdays

// This function will run when the plugin is loaded
export function activate() {
  moment.locale('es');
  moment.updateLocale('es', {
    months: "Enero_Febrero_Marzo_Abril_Mayo_Junio_Julio_Agosto_Septiembre_Octubre_Noviembre_Diciembre".split("_"),
    monthsShort: "Ene_Feb_Mar_Abr_May_Jun_Jul_Ago_Sep_Oct_Nov_Dic".split("_"),
    weekdays: "Domingo_Lunes_Martes_Miércoles_Jueves_Viernes_Sábado".split("_"),
    weekdaysShort: "Dom_Lun_Mar_Mié_Jue_Vie_Sáb".split("_"),
    weekdaysMin: "Do_Lu_Ma_Mi_Ju_Vi_Sá".split("_")
  });
}

What I’m trying to do

Problem is i don’t got a clue on how or where to append it to obsidian in order to load it when launching (so it updates the locale before using it on calendar, daily notes, dataview and so on)

Some in this forum speaks of a javascript init plugin which is capable of running javascript at a pretty early stage, maybe that is the solution for you?

1 Like

It worked like a charm, again, thank you!

plugin code for the interested:

// Manipula el locale (es) actual de moment.js y muestra los dias de la semana y sus abreviaciones con mayúsculas en la primera letra
moment.locale('es', {
  weekdays: 'Domingo_Lunes_Martes_Miércoles_Jueves_Viernes_Sábado'.split('_'),
  weekdaysShort: 'Dom_Lun_Mar_Mié_Jue_Vie_Sáb'.split('_'),

// Manipula el locale (es) actual de moment.js y muestra los meses y sus abreviaciones con mayúsculas en la primera letra
  months: 'Enero_Febrero_Marzo_Abril_Mayo_Junio_Julio_Agosto_Septiembre_Octubre_Noviembre_Diciembre'.split('_'), 
  monthsShort: 'Ene_Feb_Mar_Abr_May_Jun_Jul_Ago_Sep_Oct_Nov_Dic'.split('_') 
});

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.