views:

338

answers:

3

I use Fullcalendar on my site, but I need all text in different language. There is piece of code in that plugin:

 // function for adding/overriding defaults

    var setDefaults = fc.setDefaults = function(d) {
    $.extend(true, defaults, d);
    };

But I have no ideas how I can use it. Please, I need help.

+1  A: 

The properties for this kind of thing are documented here:

http://arshaw.com/fullcalendar/docs/text/

Russ C
Oh, that is so obvious, I had to dig into docs one minute longer... Thank you!
tambourine
+1  A: 

Looks like it should be:

jQuery.fullCalendar.setDefaults({
    default1: 'foo',
    default2: 'fish',
    default3: 'lemon'
});

Why?

var setDefaults = fc.setDefaults = function(d) {
    $.extend(true, defaults, d);
};

setDefaults() is just a shortcut to make it easier to type. Earlier in the script var fc = $.fullCalendar = {};.

Crucially however, the line you pasted is defined within a closure, so neither setDefaults or fc is available outside the closure, so you're left with $.fullCalendar.setDefaults({}); :)

Matt
It's good explanation. I'm novice it conception of scope and stuff.
tambourine
+1  A: 

You just override the settings when creating the fullcalendar. Like this:

 var options = {
   theme: true,
   header: {
    left: 'prev,next today',
    center: 'title',
    right: 'month,agendaWeek,agendaDay'
   },
   timeFormat: {
    agenda: 'h(:mm)t{ - h(:mm)t}',
    '': 'h(:mm)t{-h(:mm)t }'
   },
   monthNames: ["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre" ], 
   monthNamesShort: ['Ene','Feb','Mar','Abr','May','Jun','Jul','Ago','Sep','Oct','Nov','Dic'],
   dayNames: [ 'Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado'],
   dayNamesShort: ['Dom','Lun','Mar','Mié','Jue','Vie','Sáb'],
   buttonText: {
    today: 'hoy',
    month: 'mes',
    week: 'semana',
    day: 'día'
   }
  };

    $('#calendar').fullCalendar(options);
Tauren
Thank! That is exactly what I need.
tambourine