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/

相关文章:

html - 全日历高度不考虑周围容器

javascript - Fullcalendar Scheduler Timeline View - 查找外部拖放事件的资源 ID

javascript - Internet Explorer 9 的 onClick 事件问题

javascript - 使用 Bootstrap 模式淡入全日历

angular - 子路由重新加载而不从父路由获取数据

typescript - Angular 7.x.x 滚动到片段的最简单方法?

javascript - 如何在没有代码 "editable = true"的情况下调整完整日历中的事件大小

angular - 如何在 Angular 7 中实现面包屑

angular - 动态更改 MatPaginatorIntl itemsPerPageLabel

angular - 如何在 Angular 7 模块设置中延迟加载模式