| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301 |
- 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_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<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('zh')];
- /// 应用名称
- ///
- /// In zh, this message translates to:
- /// **'SinoMed Cloud'**
- String get appName;
- /// 应用副标题
- ///
- /// In zh, this message translates to:
- /// **'中方诊药云'**
- String get appSubtitle;
- /// 密码登录标签
- ///
- /// In zh, this message translates to:
- /// **'密码登录'**
- String get passwordLogin;
- /// 验证码登录标签
- ///
- /// In zh, this message translates to:
- /// **'验证码登录'**
- String get smsLogin;
- /// 手机号标签
- ///
- /// In zh, this message translates to:
- /// **'手机号'**
- String get phoneNumber;
- /// 手机号输入提示
- ///
- /// In zh, this message translates to:
- /// **'请输入手机号'**
- String get phoneNumberHint;
- /// 手机号必填验证
- ///
- /// In zh, this message translates to:
- /// **'请输入手机号'**
- String get phoneNumberRequired;
- /// 手机号格式验证
- ///
- /// In zh, this message translates to:
- /// **'请输入正确的手机号'**
- String get phoneNumberInvalid;
- /// 密码标签
- ///
- /// In zh, this message translates to:
- /// **'密码'**
- String get password;
- /// 密码输入提示
- ///
- /// In zh, this message translates to:
- /// **'请输入密码'**
- String get passwordHint;
- /// 密码必填验证
- ///
- /// In zh, this message translates to:
- /// **'请输入密码'**
- String get passwordRequired;
- /// 密码长度验证
- ///
- /// In zh, this message translates to:
- /// **'密码长度不能少于6位'**
- String get passwordMinLength;
- /// 忘记密码链接
- ///
- /// In zh, this message translates to:
- /// **'忘记密码?'**
- String get forgotPassword;
- /// 忘记密码功能提示
- ///
- /// In zh, this message translates to:
- /// **'忘记密码功能待实现'**
- String get forgotPasswordNotImplemented;
- /// 登录按钮
- ///
- /// In zh, this message translates to:
- /// **'登录'**
- String get login;
- /// 退出登录按钮
- ///
- /// In zh, this message translates to:
- /// **'退出登录'**
- String get logout;
- /// 登录功能提示
- ///
- /// In zh, this message translates to:
- /// **'登录功能待实现'**
- String get loginNotImplemented;
- /// 验证码标签
- ///
- /// In zh, this message translates to:
- /// **'验证码'**
- String get smsCode;
- /// 验证码输入提示
- ///
- /// In zh, this message translates to:
- /// **'请输入验证码'**
- String get smsCodeHint;
- /// 验证码必填验证
- ///
- /// In zh, this message translates to:
- /// **'请输入验证码'**
- String get smsCodeRequired;
- /// 验证码长度验证
- ///
- /// In zh, this message translates to:
- /// **'验证码为4位数字'**
- String get smsCodeLength;
- /// 验证码格式验证
- ///
- /// In zh, this message translates to:
- /// **'验证码格式不正确'**
- String get smsCodeInvalid;
- /// 验证码已过期或未获取提示
- ///
- /// In zh, this message translates to:
- /// **'请获取验证码'**
- String get smsCodeExpired;
- /// 验证码过期提示
- ///
- /// In zh, this message translates to:
- /// **'验证码已过期'**
- String get smsCodeHasExpired;
- /// 验证码输入错误提示
- ///
- /// In zh, this message translates to:
- /// **'验证码错误'**
- String get smsCodeError;
- /// 获取验证码按钮
- ///
- /// In zh, this message translates to:
- /// **'获取验证码'**
- String get getSmsCode;
- /// 重新获取验证码按钮文本
- ///
- /// In zh, this message translates to:
- /// **'请重新获取验证码'**
- String get resendSmsCode;
- /// 验证码倒计时
- ///
- /// In zh, this message translates to:
- /// **'{count}秒'**
- String smsCodeCountdown(int count);
- /// 发送验证码时手机号必填提示
- ///
- /// In zh, this message translates to:
- /// **'请输入手机号'**
- String get phoneNumberRequiredForSms;
- }
- class _AppLocalizationsDelegate
- extends LocalizationsDelegate<AppLocalizations> {
- const _AppLocalizationsDelegate();
- @override
- Future<AppLocalizations> load(Locale locale) {
- return SynchronousFuture<AppLocalizations>(lookupAppLocalizations(locale));
- }
- @override
- bool isSupported(Locale locale) =>
- <String>['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 '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.');
- }
|