import 'dart:async'; import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:intl/intl.dart' as intl; import 'app_localizations_en.dart'; import 'app_localizations_es.dart'; import 'app_localizations_zh.dart'; // ignore_for_file: type=lint /// Callers can lookup localized strings with an instance of AppLocalizations /// returned by `AppLocalizations.of(context)`. /// /// Applications need to include `AppLocalizations.delegate()` in their app's /// `localizationDelegates` list, and the locales they support in the app's /// `supportedLocales` list. For example: /// /// ```dart /// import 'l10n/app_localizations.dart'; /// /// return MaterialApp( /// localizationsDelegates: AppLocalizations.localizationsDelegates, /// supportedLocales: AppLocalizations.supportedLocales, /// home: MyApplicationHome(), /// ); /// ``` /// /// ## Update pubspec.yaml /// /// Please make sure to update your pubspec.yaml to include the following /// packages: /// /// ```yaml /// dependencies: /// # Internationalization support. /// flutter_localizations: /// sdk: flutter /// intl: any # Use the pinned version from flutter_localizations /// /// # Rest of dependencies /// ``` /// /// ## iOS Applications /// /// iOS applications define key application metadata, including supported /// locales, in an Info.plist file that is built into the application bundle. /// To configure the locales supported by your app, you’ll need to edit this /// file. /// /// First, open your project’s ios/Runner.xcworkspace Xcode workspace file. /// Then, in the Project Navigator, open the Info.plist file under the Runner /// project’s Runner folder. /// /// Next, select the Information Property List item, select Add Item from the /// Editor menu, then select Localizations from the pop-up menu. /// /// Select and expand the newly-created Localizations item then, for each /// locale your application supports, add a new item and select the locale /// you wish to add from the pop-up menu in the Value field. This list should /// be consistent with the languages listed in the AppLocalizations.supportedLocales /// property. abstract class AppLocalizations { AppLocalizations(String locale) : localeName = intl.Intl.canonicalizedLocale(locale.toString()); final String localeName; static AppLocalizations of(BuildContext context) { return Localizations.of(context, AppLocalizations)!; } static const LocalizationsDelegate delegate = _AppLocalizationsDelegate(); /// A list of this localizations delegate along with the default localizations /// delegates. /// /// Returns a list of localizations delegates containing this delegate along with /// GlobalMaterialLocalizations.delegate, GlobalCupertinoLocalizations.delegate, /// and GlobalWidgetsLocalizations.delegate. /// /// Additional delegates can be added by appending to this list in /// MaterialApp. This list does not have to be used at all if a custom list /// of delegates is preferred or required. static const List> localizationsDelegates = >[ delegate, GlobalMaterialLocalizations.delegate, GlobalCupertinoLocalizations.delegate, GlobalWidgetsLocalizations.delegate, ]; /// A list of this localizations delegate's supported locales. static const List supportedLocales = [ Locale('en'), Locale('es'), Locale('zh'), Locale('zh', 'TW'), ]; /// No description provided for @appTitle. /// /// In en, this message translates to: /// **'PDF Signature'** String get appTitle; /// Generic error text with message /// /// In en, this message translates to: /// **'Error: {message}'** String errorWithMessage(String message); /// No description provided for @settings. /// /// In en, this message translates to: /// **'Settings'** String get settings; /// No description provided for @theme. /// /// In en, this message translates to: /// **'Theme'** String get theme; /// No description provided for @themeLight. /// /// In en, this message translates to: /// **'Light'** String get themeLight; /// No description provided for @themeDark. /// /// In en, this message translates to: /// **'Dark'** String get themeDark; /// No description provided for @themeSystem. /// /// In en, this message translates to: /// **'System'** String get themeSystem; /// No description provided for @language. /// /// In en, this message translates to: /// **'Language'** String get language; /// No description provided for @languageEnglish. /// /// In en, this message translates to: /// **'English'** String get languageEnglish; /// No description provided for @languageChineseTraditional. /// /// In en, this message translates to: /// **'Traditional Chinese'** String get languageChineseTraditional; /// No description provided for @languageSpanish. /// /// In en, this message translates to: /// **'Spanish'** String get languageSpanish; /// No description provided for @resetToDefaults. /// /// In en, this message translates to: /// **'Reset to defaults'** String get resetToDefaults; /// No description provided for @openPdf. /// /// In en, this message translates to: /// **'Open PDF...'** String get openPdf; /// No description provided for @prev. /// /// In en, this message translates to: /// **'Prev'** String get prev; /// No description provided for @next. /// /// In en, this message translates to: /// **'Next'** String get next; /// Label showing current page and total /// /// In en, this message translates to: /// **'Page {current}/{total}'** String pageInfo(int current, int total); /// No description provided for @goTo. /// /// In en, this message translates to: /// **'Go to:'** String get goTo; /// No description provided for @dpi. /// /// In en, this message translates to: /// **'DPI:'** String get dpi; /// No description provided for @saveSignedPdf. /// /// In en, this message translates to: /// **'Save Signed PDF'** String get saveSignedPdf; /// No description provided for @loadSignatureFromFile. /// /// In en, this message translates to: /// **'Load Signature from file'** String get loadSignatureFromFile; /// No description provided for @drawSignature. /// /// In en, this message translates to: /// **'Draw Signature'** String get drawSignature; /// No description provided for @noPdfLoaded. /// /// In en, this message translates to: /// **'No PDF loaded'** String get noPdfLoaded; /// No description provided for @signature. /// /// In en, this message translates to: /// **'Signature'** String get signature; /// No description provided for @lockAspectRatio. /// /// In en, this message translates to: /// **'Lock aspect ratio'** String get lockAspectRatio; /// No description provided for @backgroundRemoval. /// /// In en, this message translates to: /// **'Background removal'** String get backgroundRemoval; /// No description provided for @contrast. /// /// In en, this message translates to: /// **'Contrast'** String get contrast; /// No description provided for @brightness. /// /// In en, this message translates to: /// **'Brightness'** String get brightness; /// No description provided for @exportingPleaseWait. /// /// In en, this message translates to: /// **'Exporting... Please wait'** String get exportingPleaseWait; /// No description provided for @nothingToSaveYet. /// /// In en, this message translates to: /// **'Nothing to save yet'** String get nothingToSaveYet; /// Snackbar text showing where file saved /// /// In en, this message translates to: /// **'Saved: {path}'** String savedWithPath(String path); /// No description provided for @failedToSavePdf. /// /// In en, this message translates to: /// **'Failed to save PDF'** String get failedToSavePdf; /// No description provided for @downloadStarted. /// /// In en, this message translates to: /// **'Download started'** String get downloadStarted; /// No description provided for @failedToGeneratePdf. /// /// In en, this message translates to: /// **'Failed to generate PDF'** String get failedToGeneratePdf; /// No description provided for @invalidOrUnsupportedFile. /// /// In en, this message translates to: /// **'Invalid or unsupported file'** String get invalidOrUnsupportedFile; /// No description provided for @confirm. /// /// In en, this message translates to: /// **'Confirm'** String get confirm; /// No description provided for @undo. /// /// In en, this message translates to: /// **'Undo'** String get undo; /// No description provided for @clear. /// /// In en, this message translates to: /// **'Clear'** String get clear; } class _AppLocalizationsDelegate extends LocalizationsDelegate { const _AppLocalizationsDelegate(); @override Future load(Locale locale) { return SynchronousFuture(lookupAppLocalizations(locale)); } @override bool isSupported(Locale locale) => ['en', 'es', 'zh'].contains(locale.languageCode); @override bool shouldReload(_AppLocalizationsDelegate old) => false; } AppLocalizations lookupAppLocalizations(Locale locale) { // Lookup logic when language+country codes are specified. switch (locale.languageCode) { case 'zh': { switch (locale.countryCode) { case 'TW': return AppLocalizationsZhTw(); } break; } } // Lookup logic when only language code is specified. switch (locale.languageCode) { case 'en': return AppLocalizationsEn(); case 'es': return AppLocalizationsEs(); case 'zh': return AppLocalizationsZh(); } throw FlutterError( 'AppLocalizations.delegate failed to load unsupported locale "$locale". This is likely ' 'an issue with the localizations generation tool. Please file an issue ' 'on GitHub with a reproducible sample app and the gen-l10n configuration ' 'that was used.', ); }