问题描述
我需要在有角度的版本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.
!-开始代码段:js隐藏:虚假控制台:真babel:假->
!-- 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: []
};
}
}
我尝试在calendarOptions中添加属性locale ='es',但是它不起作用,将此添加到我的有角json中,但我不知道如何实现
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"
]
推荐答案
感谢Gabriel我使这种方法有效
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';
在html文件的全日历选择器中,应将值分配给语言环境和语言环境选项.
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];
这篇关于如何在角度7的全日历中使用语言环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!