ProSchedulerSign in

Features

Localization

One locale object sets the language of every date, weekday and month name through Intl, the first day of the week, and every string the component shows.

Built-in locales

Locales that ship with the package
ExportLanguageWeek starts
localeEnEnglish (default)Monday
localeEsSpanishMonday
localeFrFrenchMonday
localeDeGermanMonday
localePtBrPortuguese (Brazil)Sunday
localePtPtPortuguese (Portugal)Monday
import { ProScheduler, localeFr } from "@andreisaac/pro-scheduler"

<ProScheduler locale={localeFr} … />
Live demo

Five languages, one component

Switch language: day and month names, the first weekday and the UI labels all follow.

import { useMemo, useState, useSyncExternalStore } from "react"
import { localeDe, localeEn, localeEs, localeFr, localePtBr, ProScheduler, type SchedulerEvent, type SchedulerLocale } from "@/components/pro-scheduler"
import { studioEvents, studioResources } from "@/lib/demo-data/studio"

const subscribe = () => () => {}

/** False during the server render and hydration, true afterwards. */
function useHydrated() {
  return useSyncExternalStore(subscribe, () => true, () => false)
}

function Placeholder({ height }: { height: number }) {
  return <div aria-hidden className="docs-demo__placeholder" style={{ height }} />
}

/**
 * ProScheduler is controlled: it never edits `data` itself. The callbacks below
 * are the whole contract — apply the change, and the view re-renders from it.
 */
function useEvents(initial: () => SchedulerEvent[]) {
  const [events, setEvents] = useState(initial)

  const handlers = useMemo(
    () => ({
      onEventCreated: (event: SchedulerEvent) =>
        setEvents((list) => [...list, { ...event, id: crypto.randomUUID() }]),
      onEventUpdated: (event: SchedulerEvent) =>
        setEvents((list) => list.map((e) => (e.id === event.id ? event : e))),
      onEventDeleted: (event: SchedulerEvent) =>
        setEvents((list) => list.filter((e) => e.id !== event.id)),
    }),
    []
  )

  return { events, setEvents, handlers }
}

const locales: Record<string, SchedulerLocale> = {
  English: localeEn,
  Français: localeFr,
  Deutsch: localeDe,
  Español: localeEs,
  "Português (BR)": localePtBr,
}

export function LocalizationDemo() {
  const hydrated = useHydrated()
  const { events, handlers } = useEvents(studioEvents)
  const [language, setLanguage] = useState("Français")
  if (!hydrated) return <Placeholder height={600} />

  return (
    <div className="docs-demo__stack">
      <div className="docs-demo__toolbar" role="group" aria-label="Language">
        {Object.keys(locales).map((name) => (
          <button key={name} type="button" aria-pressed={language === name} onClick={() => setLanguage(name)}>
            {name}
          </button>
        ))}
      </div>
      <ProScheduler
        data={events}
        resources={studioResources}
        locale={locales[language]}
        view={{ calendar: { type: "month" }, agenda: { type: "day" } }}
        height={560}
        {...handlers}
      />
    </div>
  )
}

Any other language

Date formatting goes through Intl.DateTimeFormat with the locale’s code, so no month or weekday tables are needed — only the component’s own labels. Spread a built-in locale and translate the strings. Names that some languages write in lower case are capitalized for headings automatically.

import { localeEn, type SchedulerLocale } from "@andreisaac/pro-scheduler"

export const localeIt: SchedulerLocale = {
  ...localeEn,              // start from any built-in, override the rest
  code: "it-IT",            // Intl formats dates and names in Italian
  firstDay: 1,              // Monday
  todayText: "Oggi",
  allDayText: "Tutto il giorno",
  noEventsText: "Nessun evento",
  newEventText: "Nuovo evento",
  editEventText: "Modifica evento",
  saveText: "Salva",
  cancelText: "Annulla",
  deleteText: "Elimina",
  dayText: "Giorno",
  weekText: "Settimana",
  monthText: "Mese",
  yearText: "Anno",
  // …the remaining labels
}

The locale object is plain data and is also exported from @andreisaac/pro-scheduler/server, so a server component can choose it from the request’s language before rendering.