Localization in Flutter PDF Viewer (SfPdfViewer)
10 Jul 20261 minute to read
By default, the SfPdfViewer widget supports US English localization. You can change to other languages by specifying the MaterialApp properties and adding the flutter_localizations and syncfusion_localizations packages to your application.
To use flutter_localizations and syncfusion_localizations, add the packages as a dependency to the pubspec.yaml file.
dependencies:
flutter_localizations:
sdk: flutter
syncfusion_localizations: ^XX.X.XXNext, import the flutter_localizations and syncfusion_localizations libraries and specify the localizationsDelegates and supportedLocales for MaterialApp to localize the contents in the SfPdfViewer (page navigation dialog and bookmark view).
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:syncfusion_localizations/syncfusion_localizations.dart';
@override
Widget build(BuildContext context) {
return MaterialApp(
localizationsDelegates: [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
SfGlobalLocalizations.delegate,
],
supportedLocales: [
const Locale('fr'),
const Locale('ru'),
const Locale('ta'),
],
locale: const Locale('fr'),
title: 'PDF Viewer Localization',
home: Scaffold(
appBar: AppBar(
title: Text('Flutter PDF Viewer'),
),
body: SfPdfViewer.network(
'https://cdn.syncfusion.com/content/PDFViewer/flutter-succinctly.pdf'),
),
);
}