最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Change the language of the Fullcalendar React component - Stack Overflow

programmeradmin2浏览0评论

I cannot find on the fullcalendar documentation how to set the locale for the React component ().

This is how I'm using the component:

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>
    );

}

How can I set the language to Spanish?

I cannot find on the fullcalendar documentation how to set the locale for the React component (https://fullcalendar.io/docs/react).

This is how I'm using the component:

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>
    );

}

How can I set the language to Spanish?

Share Improve this question edited Sep 6, 2021 at 13:10 Agu Dondo asked Sep 3, 2021 at 16:14 Agu DondoAgu Dondo 13.6k7 gold badges62 silver badges70 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 19

The locale can be set on the Fullcalendar React component like this:

  1. Run: yarn add @fullcalendar/core

  2. Import the locale: import esLocale from '@fullcalendar/core/locales/es';

  3. Pass the locale as a prop to the component:

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

To complement the answer of Agu Dondo, you can import all languages available.

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

And later, to the component FullCalendar, add locales and in locale use the abbreviation language like es or ca.

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

评论列表(0)

  1. 暂无评论