• Resolved lemonart

    (@lemonart)


    Hi! I just read that is not possible to change the language of the code but just wanted to check if someone managed to change the name of the months and initianls of the days of the week in the calendar with code.

    Trying to set them into spanish

    Days of the week

    L, M, X, J, V, S, D

    And months

    Enero
    Febrero
    Marzo
    Abril
    Mayo
    Junio
    Julio
    Agosto
    Septiembre
    Octubre
    Noviembre
    Diciembre

Viewing 1 replies (of 1 total)
  • Plugin Author i4nd90

    (@i4nd90)

    The plugin utilises the Javascript library moment.js in which you can set a locale to have this done automatically for you. In the example below, I have extracted the Spanish locale from the moment source code and set it to load just before the CLNDR instance. You would place this code in your theme’s functions.php file.

    function load_moment_locale() {
    
    echo "
    <script>
       
    //! moment.js locale configuration
    //! locale : Spanish [es]
    //! author : Julio Napurí : https://github.com/julionc
    
    var monthsShortDot$1 = 'ene._feb._mar._abr._may._jun._jul._ago._sep._oct._nov._dic.'.split('_');
    var monthsShort$2 = 'ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic'.split('_');
    
    moment.locale('es', {
        months : 'enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre'.split('_'),
        monthsShort : function (m, format) {
            if (/-MMM-/.test(format)) {
                return monthsShort$2[m.month()];
            } else {
                return monthsShortDot$1[m.month()];
            }
        },
        monthsParseExact : true,
        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('_'),
        weekdaysParseExact : true,
        longDateFormat : {
            LT : 'H:mm',
            LTS : 'H:mm:ss',
            L : 'DD/MM/YYYY',
            LL : 'D [de] MMMM [de] YYYY',
            LLL : 'D [de] MMMM [de] YYYY H:mm',
            LLLL : 'dddd, D [de] MMMM [de] YYYY H:mm'
        },
        calendar : {
            sameDay : function () {
                return '[hoy a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
            },
            nextDay : function () {
                return '[ma?ana a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
            },
            nextWeek : function () {
                return 'dddd [a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
            },
            lastDay : function () {
                return '[ayer a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
            },
            lastWeek : function () {
                return '[el] dddd [pasado a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
            },
            sameElse : 'L'
        },
        relativeTime : {
            future : 'en %s',
            past : 'hace %s',
            s : 'unos segundos',
            m : 'un minuto',
            mm : '%d minutos',
            h : 'una hora',
            hh : '%d horas',
            d : 'un día',
            dd : '%d días',
            M : 'un mes',
            MM : '%d meses',
            y : 'un a?o',
            yy : '%d a?os'
        },
        ordinalParse : /\d{1,2}o/,
        ordinal : '%do',
        week : {
            dow : 1, // Monday is the first day of the week.
            doy : 4  // The week that contains Jan 4th is the first week of the year.
        }
    });
    
    </script>
       
    ";
    }
    
    add_action( 'wp_print_footer_scripts', 'load_moment_locale', 99 );

    Note: Because this locale sets the day of the week [dow] to 1, the weekOffset set in the plugin instance is now relative to this – so if you were using one of the shipped pre-loaded instances where this was set to 1, the calendar would now start on Tuesday. If this is undesired, simply remove this setting.

    I’m aware this is perhaps a bit of a messy workaround and may provide an update in the future to make the process of setting locale a bit easier.

    Let me know if this works for you.

    • This reply was modified 8 years ago by i4nd90.
Viewing 1 replies (of 1 total)
  • The topic ‘Change language of month and days’ is closed to new replies.