我在完整的日历文档中找不到如何设置React组件的区域设置(https://fullcalendar.io/docs/react)。
我是这样使用组件的:
import FullCalendar from '@fullcalendar/react' // must go before plugins
import dayGridPlugin from '@fullcalendar/daygrid' // a plugin!
export default function Calendar(props){
return (
<Box>
<FullCalendar
plugins={[ dayGridPlugin ]}
initialView="dayGridMonth"
/>
</Box>
);
}
如何将语言设置为西班牙语?
区域设置可以像这样在Fullcalendar React组件上设置:
-
Run:
yarn add @fullcalendar/core
-
导入语言环境:
import esLocale from '@fullcalendar/core/locales/es';
-
将区域设置作为道具传递给组件:
<FullCalendar locale={esLocale} plugins={[ dayGridPlugin ]} initialView="dayGridMonth" />
为了补充Agu Dondo的答案,您可以导入所有可用的语言。
import allLocales from '@fullcalendar/core/locales-all'
之后,在FullCalendar
中加入locales
,在locale
中使用es
或ca
的缩写语言。
<FullCalendar locales={allLocales} locale={'es'} plugins={[ dayGridPlugin ]} initialView="dayGridMonth" />