Articles in this section
Category / Section

How to override the localization in the Flutter Calendar

1 min read

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

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied