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'; import 'app_localizations_es.dart'; import 'app_localizations_fr.dart'; import 'app_localizations_it.dart'; import 'app_localizations_pt.dart'; import 'app_localizations_ru.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('de'), Locale('en'), Locale('es'), Locale('fr'), Locale('it'), Locale('pt'), Locale('ru'), Locale('zh'), ]; /// No description provided for @appTitle. /// /// In it, this message translates to: /// **'TetraQ'** String get appTitle; /// No description provided for @welcomeTitle. /// /// In it, this message translates to: /// **'BENVENUTO IN TETRAQ!'** String get welcomeTitle; /// No description provided for @nameHint. /// /// In it, this message translates to: /// **'NOME'** String get nameHint; /// No description provided for @saveAndPlay. /// /// In it, this message translates to: /// **'SALVA E GIOCA'** String get saveAndPlay; /// No description provided for @onlineTitle. /// /// In it, this message translates to: /// **'ONLINE'** String get onlineTitle; /// No description provided for @onlineSub. /// /// In it, this message translates to: /// **'Sfida il mondo'** String get onlineSub; /// No description provided for @cpuTitle. /// /// In it, this message translates to: /// **'VS CPU'** String get cpuTitle; /// No description provided for @cpuSub. /// /// In it, this message translates to: /// **'Allenati con l\'IA'** String get cpuSub; /// No description provided for @localTitle. /// /// In it, this message translates to: /// **'LOCALE'** String get localTitle; /// No description provided for @localSub. /// /// In it, this message translates to: /// **'Stesso schermo'** String get localSub; /// No description provided for @leaderboardTitle. /// /// In it, this message translates to: /// **'CLASSIFICA'** String get leaderboardTitle; /// No description provided for @questsTitle. /// /// In it, this message translates to: /// **'SFIDE'** String get questsTitle; /// No description provided for @themesTitle. /// /// In it, this message translates to: /// **'TEMI'** String get themesTitle; /// No description provided for @tutorialTitle. /// /// In it, this message translates to: /// **'TUTORIAL'** String get tutorialTitle; /// No description provided for @startGame. /// /// In it, this message translates to: /// **'AVVIA PARTITA'** String get startGame; /// No description provided for @createMatch. /// /// In it, this message translates to: /// **'CREA PARTITA'** String get createMatch; /// No description provided for @joinMatch. /// /// In it, this message translates to: /// **'UNISCITI'** String get joinMatch; /// No description provided for @gameOver. /// /// In it, this message translates to: /// **'FINE PARTITA'** String get gameOver; /// No description provided for @mainMenu. /// /// In it, this message translates to: /// **'TORNA AL MENU'** String get mainMenu; /// No description provided for @exit. /// /// In it, this message translates to: /// **'ESCI'** String get exit; } class _AppLocalizationsDelegate extends LocalizationsDelegate { const _AppLocalizationsDelegate(); @override Future load(Locale locale) { return SynchronousFuture(lookupAppLocalizations(locale)); } @override bool isSupported(Locale locale) => [ 'de', 'en', 'es', 'fr', 'it', 'pt', 'ru', 'zh', ].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(); case 'es': return AppLocalizationsEs(); case 'fr': return AppLocalizationsFr(); case 'it': return AppLocalizationsIt(); case 'pt': return AppLocalizationsPt(); case 'ru': return AppLocalizationsRu(); 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.', ); }