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_de.dart'; import 'app_localizations_en.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('de'), Locale('en'), ]; /// No description provided for @appTitle. /// /// In en, this message translates to: /// **'Agenda Tasks'** String get appTitle; /// No description provided for @calendar. /// /// In en, this message translates to: /// **'Calendar'** String get calendar; /// No description provided for @settings. /// /// In en, this message translates to: /// **'Settings'** String get settings; /// No description provided for @noTasks. /// /// In en, this message translates to: /// **'No tasks for today'** String get noTasks; /// No description provided for @errorOccurred. /// /// In en, this message translates to: /// **'An error occurred'** String get errorOccurred; /// No description provided for @retry. /// /// In en, this message translates to: /// **'Retry'** String get retry; /// No description provided for @newTask. /// /// In en, this message translates to: /// **'New Task'** String get newTask; /// No description provided for @editTask. /// /// In en, this message translates to: /// **'Edit Task'** String get editTask; /// No description provided for @save. /// /// In en, this message translates to: /// **'Save'** String get save; /// No description provided for @cancel. /// /// In en, this message translates to: /// **'Cancel'** String get cancel; /// No description provided for @delete. /// /// In en, this message translates to: /// **'Delete'** String get delete; /// No description provided for @title. /// /// In en, this message translates to: /// **'Title'** String get title; /// No description provided for @titleRequired. /// /// In en, this message translates to: /// **'Title is required'** String get titleRequired; /// No description provided for @description. /// /// In en, this message translates to: /// **'Description'** String get description; /// No description provided for @date. /// /// In en, this message translates to: /// **'Date'** String get date; /// No description provided for @priority. /// /// In en, this message translates to: /// **'Priority'** String get priority; /// No description provided for @priorityLow. /// /// In en, this message translates to: /// **'Low'** String get priorityLow; /// No description provided for @priorityMedium. /// /// In en, this message translates to: /// **'Medium'** String get priorityMedium; /// No description provided for @priorityHigh. /// /// In en, this message translates to: /// **'High'** String get priorityHigh; /// No description provided for @filterAll. /// /// In en, this message translates to: /// **'All'** String get filterAll; /// No description provided for @filterActive. /// /// In en, this message translates to: /// **'Active'** String get filterActive; /// No description provided for @filterCompleted. /// /// In en, this message translates to: /// **'Completed'** String get filterCompleted; /// No description provided for @deleteTask. /// /// In en, this message translates to: /// **'Delete Task'** String get deleteTask; /// No description provided for @deleteTaskConfirm. /// /// In en, this message translates to: /// **'Are you sure you want to delete this task?'** String get deleteTaskConfirm; /// No description provided for @rescheduleToTomorrow. /// /// In en, this message translates to: /// **'Move to tomorrow'** String get rescheduleToTomorrow; /// No description provided for @goToDay. /// /// In en, this message translates to: /// **'Go to day'** String get goToDay; /// No description provided for @general. /// /// In en, this message translates to: /// **'General'** String get general; /// No description provided for @language. /// /// In en, this message translates to: /// **'Language'** String get language; /// No description provided for @systemDefault. /// /// In en, this message translates to: /// **'System default'** String get systemDefault; /// No description provided for @appearance. /// /// In en, this message translates to: /// **'Appearance'** String get appearance; /// No description provided for @darkMode. /// /// In en, this message translates to: /// **'Theme'** String get darkMode; /// No description provided for @lightMode. /// /// In en, this message translates to: /// **'Light'** String get lightMode; /// No description provided for @darkModeOption. /// /// In en, this message translates to: /// **'Dark'** String get darkModeOption; /// No description provided for @about. /// /// In en, this message translates to: /// **'About'** String get about; /// No description provided for @version. /// /// In en, this message translates to: /// **'Version'** String get version; } class _AppLocalizationsDelegate extends LocalizationsDelegate { const _AppLocalizationsDelegate(); @override Future load(Locale locale) { return SynchronousFuture(lookupAppLocalizations(locale)); } @override bool isSupported(Locale locale) => ['de', 'en'].contains(locale.languageCode); @override bool shouldReload(_AppLocalizationsDelegate old) => false; } AppLocalizations lookupAppLocalizations(Locale locale) { // Lookup logic when only language code is specified. switch (locale.languageCode) { case 'de': return AppLocalizationsDe(); case 'en': return AppLocalizationsEn(); } 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.', ); }