We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to override the localization in the Flutter Calendar


In the Flutter Event Calendar, you can override the localization by using the extendibility options.

STEP 1: Add the localization_extendibility.dart file inside the lib folder.

localization

STEP 2: Override the required keyword like the following code snippet.

allowed views label

STEP 3: Add the delegate class for localization in localization_extendibility.dart file.

class SfLocalizationsFrDelegate extends LocalizationsDelegate<SfLocalizations> {
  const SfLocalizationsFrDelegate();
 
  @override
  bool isSupported(Locale locale) => locale.languageCode == 'fr';
 
  @override
  Future<SfLocalizations> load(Locale locale) {
    return SynchronousFuture<SfLocalizations>(SfLocalizationsFr());
  }
 
  @override
  bool shouldReload(LocalizationsDelegate<SfLocalizations> old) => true;
}

STEP 4: Then call the delegate class to override the localized words.

import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_calendar/calendar.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
 
import './localization_extendability.dart';
 
void main() {
  return runApp(Extendibility());
}
 
class Extendibility extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      localizationsDelegates: [
        GlobalMaterialLocalizations.delegate,
        //Specify the delegate directly
        SfLocalizationsFrDelegate()
      ],
      supportedLocales: [
        const Locale('en'),
        const Locale('et'),
        const Locale('fr'),
      ],
      locale: const Locale('fr'),
      home: FlutterLocale(),
    );
  }
}
 
class FlutterLocale extends StatefulWidget {
  @override
  _FlutterLocaleState createState() => _FlutterLocaleState();
}
 
class _FlutterLocaleState extends State<FlutterLocale> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(),
        body: SfCalendar(
          view: CalendarView.month,
          allowedViews: [
            CalendarView.schedule,
            CalendarView.day,
            CalendarView.week,
            CalendarView.timelineMonth
          ],
        ));
  }
}

View sample in GitHub

localization

 

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile