Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use locale in fullcalendar in angular 7

I need to change the language of my calendar in the angular version 7. I have not found much documentation about this. The main thing is to change the language of the days that appear on the calendar.

!-- begin snippet: js hide: false console: true babel: false -->

import { Component, OnInit, ViewChild } from '@angular/core';
import { CalendarComponent } from 'ng-fullcalendar';
import { Options } from 'fullcalendar';

@Component({
  selector: 'app-calendario',
  templateUrl: './calendario.component.html',
  styleUrls: ['./calendario.component.css']
})
export class CalendarioComponent implements OnInit {
  //calendario
  calendarOptions: Options;
  displayEvent: any;
  @ViewChild(CalendarComponent) ucCalendar: CalendarComponent;

  constructor() { }

  ngOnInit() {

    this.calendarOptions = {
      editable: true,
      eventLimit: false,
      header: {
        left: '',
        center: 'title',
        right: 'month'
      },

      events: []
    };
  }      

}

I try to add the property locale = 'es' in the calendarOptions, but it does not work, add this to my angular json, but I do not know how to implement it

     "scripts": [
              "node_modules/fullcalendar/dist/locale/es.js"
            ]
like image 372
Erley Blanco C Avatar asked Mar 03 '23 18:03

Erley Blanco C


1 Answers

Thanks Gabriel I make it work with this approach

First make sure you have the import of your desire lenguage

import esLocale from '@fullcalendar/core/locales/es';
import frLocale from '@fullcalendar/core/locales/fr';

In your html file, in the full-calendar selector, you should assign values to locales and locale options.

    <full-calendar
    defaultView="dayGridMonth"
    [locales]="locales"
    locale="es"
    [weekends]="false"
    [plugins]="calendarPlugins"></full-calendar>

Then a variable that holds all the languages that you need

locales = [esLocale, frLocale];
like image 91
Okyam Avatar answered Apr 25 '23 01:04

Okyam