fullcalendar - 如何在 angular 7 的 fullcalendar 中使用语言环境

标签 fullcalendar angular7

我需要在 angular 版本 7 中更改日历的语言。我没有找到太多关于此的文档。最主要的是更改日历上出现的日期的语言。

!-- 开始片段: js hide: false 控制台: 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: []
    };
  }      

}

我尝试在日历选项中添加属性 locale = 'es',但它不起作用,
将此添加到我的 angular json,但我不知道如何实现它

     "scripts": [
              "node_modules/fullcalendar/dist/locale/es.js"
            ]

最佳答案

谢谢加布里埃尔我用这种方法让它工作

首先确保您导入了您想要的语言

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

在您的 html 文件中,在完整日历选择器中,您应该为区域设置和区域设置选项分配值。
    <full-calendar
    defaultView="dayGridMonth"
    [locales]="locales"
    locale="es"
    [weekends]="false"
    [plugins]="calendarPlugins"></full-calendar>

然后是一个包含您需要的所有语言的变量
locales = [esLocale, frLocale];

关于fullcalendar - 如何在 angular 7 的 fullcalendar 中使用语言环境,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56889727/

相关文章:

javascript - 无法读取未定义的属性 'clone'

javascript - 使用多个日历时完整日历事件消失 - Meteor

javascript - 如何显示 JSON feed 中的特定事件

angular - 如何在 Angular 7 中增加超过 2 分钟的 HTTP 请求超时?

angular - 如何在 Moment js 中设置有效的空日期?

javascript - Auth0 Angular 7登录重定向循环

javascript - fullcalendar - 结束日期不正确

jquery - 如何在 Fullcalendar Jquery 中将时间段选择限制为一天?

javascript - @Input 属性没有被第二次更新

arrays - 嵌套 *ngFors - 更好的选择? ( Angular 7)