修改Fullcalendar React组件的语言



我在完整的日历文档中找不到如何设置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组件上设置:

  1. Run:yarn add @fullcalendar/core

  2. 导入语言环境:import esLocale from '@fullcalendar/core/locales/es';

  3. 将区域设置作为道具传递给组件:

    <FullCalendar locale={esLocale} plugins={[ dayGridPlugin ]} initialView="dayGridMonth" />
    

为了补充Agu Dondo的答案,您可以导入所有可用的语言。

import allLocales from '@fullcalendar/core/locales-all'

之后,在FullCalendar中加入locales,在locale中使用esca的缩写语言。

<FullCalendar locales={allLocales} locale={'es'} plugins={[ dayGridPlugin ]} initialView="dayGridMonth" />

最新更新