357 lines
11 KiB
Dart
357 lines
11 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_en.dart';
|
||
import 'app_localizations_th.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('en'),
|
||
Locale('th'),
|
||
];
|
||
|
||
/// No description provided for @deviceList.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Device List'**
|
||
String get deviceList;
|
||
|
||
/// No description provided for @noDevices.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'It seems that you have no devices! You can register one with the big plus button.'**
|
||
String get noDevices;
|
||
|
||
/// No description provided for @setupNewDevice.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Setup new device'**
|
||
String get setupNewDevice;
|
||
|
||
/// No description provided for @addExistingDevice.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Add existing device'**
|
||
String get addExistingDevice;
|
||
|
||
/// No description provided for @nfcDisabled.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'NFC is disabled on your device!'**
|
||
String get nfcDisabled;
|
||
|
||
/// No description provided for @nfcRequired.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'This app requires NFC as part of the core functionality.'**
|
||
String get nfcRequired;
|
||
|
||
/// No description provided for @nfcUnsupported.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Your device does not support NFC'**
|
||
String get nfcUnsupported;
|
||
|
||
/// No description provided for @nfcReady.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'NFC is ready!'**
|
||
String get nfcReady;
|
||
|
||
/// No description provided for @nfcReadyDescription.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'You can tap the device with the NFC scanner now.'**
|
||
String get nfcReadyDescription;
|
||
|
||
/// No description provided for @registerDevice.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Register Device'**
|
||
String get registerDevice;
|
||
|
||
/// No description provided for @deviceName.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Name'**
|
||
String get deviceName;
|
||
|
||
/// No description provided for @networkName.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Network Name (SSID)'**
|
||
String get networkName;
|
||
|
||
/// No description provided for @routerMacAddress.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Router MAC Address (BSSID)'**
|
||
String get routerMacAddress;
|
||
|
||
/// No description provided for @networkPassword.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Network Password'**
|
||
String get networkPassword;
|
||
|
||
/// No description provided for @networkLimitation.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Only 2.4 GHz networks allowed!'**
|
||
String get networkLimitation;
|
||
|
||
/// No description provided for @networkLimitationDesc.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'We suspect that your network may be 5 GHz based on the name. Please note that liteauth can only connect to 2.4 GHz networks.'**
|
||
String get networkLimitationDesc;
|
||
|
||
/// No description provided for @networkInitHeadline.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Network Initialization'**
|
||
String get networkInitHeadline;
|
||
|
||
/// No description provided for @networkInitDetails.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Broadcasting network information to your liteauth device, This will be done in a minute or two. Please also make sure your device is powered on.'**
|
||
String get networkInitDetails;
|
||
|
||
/// No description provided for @networkInfoHeadline.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Network Information'**
|
||
String get networkInfoHeadline;
|
||
|
||
/// No description provided for @networkInfoPrompt.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Do you wish to automatically fill in the current network information? The app will ask to access your fine location if you continue.'**
|
||
String get networkInfoPrompt;
|
||
|
||
/// No description provided for @continueText.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Continue'**
|
||
String get continueText;
|
||
|
||
/// No description provided for @cancel.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Cancel'**
|
||
String get cancel;
|
||
|
||
/// No description provided for @deviceInfo.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Device Information'**
|
||
String get deviceInfo;
|
||
|
||
/// No description provided for @delete.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Delete'**
|
||
String get delete;
|
||
|
||
/// No description provided for @deletion.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Deletion'**
|
||
String get deletion;
|
||
|
||
/// No description provided for @deviceDeleteConfirm.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Are you sure you want to delete this device forever?'**
|
||
String get deviceDeleteConfirm;
|
||
|
||
/// No description provided for @reconfigureNetwork.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Reconfigure Network'**
|
||
String get reconfigureNetwork;
|
||
|
||
/// No description provided for @factoryReset.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Factory Reset'**
|
||
String get factoryReset;
|
||
|
||
/// No description provided for @resetConfirm.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Are you sure you want to proceed with the factory reset? Your data will be lost and unrecoverable, and you must setup the device again.'**
|
||
String get resetConfirm;
|
||
|
||
/// No description provided for @reset.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Reset'**
|
||
String get reset;
|
||
|
||
/// No description provided for @status.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Status: '**
|
||
String get status;
|
||
|
||
/// No description provided for @online.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Online'**
|
||
String get online;
|
||
|
||
/// No description provided for @offline.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Offline'**
|
||
String get offline;
|
||
|
||
/// No description provided for @refresh.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Refresh'**
|
||
String get refresh;
|
||
|
||
/// No description provided for @lastKnownIP.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Last Known IP: {ip}'**
|
||
String lastKnownIP(String ip);
|
||
|
||
/// No description provided for @routerSsid.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Router SSID: {ssid}'**
|
||
String routerSsid(String ssid);
|
||
|
||
/// No description provided for @activityLogs.
|
||
///
|
||
/// In en, this message translates to:
|
||
/// **'Activity Logs'**
|
||
String get activityLogs;
|
||
}
|
||
|
||
class _AppLocalizationsDelegate
|
||
extends LocalizationsDelegate<AppLocalizations> {
|
||
const _AppLocalizationsDelegate();
|
||
|
||
@override
|
||
Future<AppLocalizations> load(Locale locale) {
|
||
return SynchronousFuture<AppLocalizations>(lookupAppLocalizations(locale));
|
||
}
|
||
|
||
@override
|
||
bool isSupported(Locale locale) =>
|
||
<String>['en', 'th'].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 'en':
|
||
return AppLocalizationsEn();
|
||
case 'th':
|
||
return AppLocalizationsTh();
|
||
}
|
||
|
||
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.',
|
||
);
|
||
}
|