379 lines
10 KiB
Dart
379 lines
10 KiB
Dart
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_ar.dart';
|
||
import 'app_localizations_en.dart';
|
||
import 'app_localizations_fr.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<AppLocalizations>(context, AppLocalizations)!;
|
||
}
|
||
|
||
static const LocalizationsDelegate<AppLocalizations> 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<LocalizationsDelegate<dynamic>> localizationsDelegates =
|
||
<LocalizationsDelegate<dynamic>>[
|
||
delegate,
|
||
GlobalMaterialLocalizations.delegate,
|
||
GlobalCupertinoLocalizations.delegate,
|
||
GlobalWidgetsLocalizations.delegate,
|
||
];
|
||
|
||
/// A list of this localizations delegate's supported locales.
|
||
static const List<Locale> supportedLocales = <Locale>[
|
||
Locale('ar'),
|
||
Locale('en'),
|
||
Locale('fr'),
|
||
];
|
||
|
||
/// No description provided for @appName.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'KriTomobil'**
|
||
String get appName;
|
||
|
||
/// No description provided for @tagline.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'The easiest way to find\nand reserve your perfect car'**
|
||
String get tagline;
|
||
|
||
/// No description provided for @findYourCar.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Find your car'**
|
||
String get findYourCar;
|
||
|
||
/// No description provided for @companySignIn.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Space Agency'**
|
||
String get companySignIn;
|
||
|
||
/// No description provided for @sameDropoff.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Same drop-off'**
|
||
String get sameDropoff;
|
||
|
||
/// No description provided for @differentDropoff.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Different drop-off'**
|
||
String get differentDropoff;
|
||
|
||
/// No description provided for @findCarToRent.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Find a car to rent'**
|
||
String get findCarToRent;
|
||
|
||
/// No description provided for @allCarTypes.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'All car types'**
|
||
String get allCarTypes;
|
||
|
||
/// No description provided for @search.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Search'**
|
||
String get search;
|
||
|
||
/// No description provided for @searching.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Searching…'**
|
||
String get searching;
|
||
|
||
/// No description provided for @vehiclesFound.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'{count, plural, =0{No vehicles found} =1{1 vehicle found} other{{count} vehicles found}}'**
|
||
String vehiclesFound(num count);
|
||
|
||
/// No description provided for @noVehiclesFound.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'No vehicles found'**
|
||
String get noVehiclesFound;
|
||
|
||
/// No description provided for @tryDifferentSearch.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Try different dates, city, or car type'**
|
||
String get tryDifferentSearch;
|
||
|
||
/// No description provided for @couldNotLoadVehicles.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Could not load vehicles'**
|
||
String get couldNotLoadVehicles;
|
||
|
||
/// No description provided for @checkConnectionRetry.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Check your connection and try again'**
|
||
String get checkConnectionRetry;
|
||
|
||
/// No description provided for @retry.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Retry'**
|
||
String get retry;
|
||
|
||
/// No description provided for @myBookings.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'My Bookings'**
|
||
String get myBookings;
|
||
|
||
/// No description provided for @browse.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Browse'**
|
||
String get browse;
|
||
|
||
/// No description provided for @signInToViewBookings.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Sign in to view your bookings'**
|
||
String get signInToViewBookings;
|
||
|
||
/// No description provided for @carType.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Car type'**
|
||
String get carType;
|
||
|
||
/// No description provided for @selectCity.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Select city'**
|
||
String get selectCity;
|
||
|
||
/// No description provided for @allCities.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'All cities'**
|
||
String get allCities;
|
||
|
||
/// No description provided for @searchCities.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Search cities…'**
|
||
String get searchCities;
|
||
|
||
/// No description provided for @chooseLanguage.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Language'**
|
||
String get chooseLanguage;
|
||
|
||
/// No description provided for @languageName.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'English'**
|
||
String get languageName;
|
||
|
||
/// No description provided for @perDay.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'/day'**
|
||
String get perDay;
|
||
|
||
/// No description provided for @nDays.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'{count, plural, =1{1 day} other{{count} days}}'**
|
||
String nDays(num count);
|
||
|
||
/// No description provided for @total.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'total'**
|
||
String get total;
|
||
|
||
/// No description provided for @reserveThisCar.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Reserve This Car'**
|
||
String get reserveThisCar;
|
||
|
||
/// No description provided for @lightTheme.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Light'**
|
||
String get lightTheme;
|
||
|
||
/// No description provided for @darkTheme.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Dark'**
|
||
String get darkTheme;
|
||
|
||
/// No description provided for @settings.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Settings'**
|
||
String get settings;
|
||
|
||
/// No description provided for @anyPrice.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Any price'**
|
||
String get anyPrice;
|
||
|
||
/// No description provided for @price.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Price'**
|
||
String get price;
|
||
|
||
/// No description provided for @apply.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Apply'**
|
||
String get apply;
|
||
|
||
/// No description provided for @selectAll.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Select all'**
|
||
String get selectAll;
|
||
|
||
/// No description provided for @clearAll.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Clear all'**
|
||
String get clearAll;
|
||
|
||
/// No description provided for @pickDates.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Pick dates'**
|
||
String get pickDates;
|
||
|
||
/// No description provided for @pickupLocation.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Pickup location'**
|
||
String get pickupLocation;
|
||
|
||
/// No description provided for @dropoffLocation.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Drop-off location'**
|
||
String get dropoffLocation;
|
||
}
|
||
|
||
class _AppLocalizationsDelegate
|
||
extends LocalizationsDelegate<AppLocalizations> {
|
||
const _AppLocalizationsDelegate();
|
||
|
||
@override
|
||
Future<AppLocalizations> load(Locale locale) {
|
||
return SynchronousFuture<AppLocalizations>(lookupAppLocalizations(locale));
|
||
}
|
||
|
||
@override
|
||
bool isSupported(Locale locale) =>
|
||
<String>['ar', 'en', 'fr'].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 'ar':
|
||
return AppLocalizationsAr();
|
||
case 'en':
|
||
return AppLocalizationsEn();
|
||
case 'fr':
|
||
return AppLocalizationsFr();
|
||
}
|
||
|
||
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.',
|
||
);
|
||
}
|