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(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('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 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 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 mine; /// 修改密码按钮 /// /// In zh, this message translates to: /// **'修改密码'** String get changePassword; /// 修改密码成功提示 /// /// In zh, this message translates to: /// **'修改密码成功'** String get changePasswordSuccess; /// 修改密码失败提示 /// /// In zh, this message translates to: /// **'修改密码失败'** String get changePasswordFailed; /// 登录功能提示 /// /// 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 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 smsCodeSent; /// 重新获取验证码按钮文本 /// /// 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 newPassword; /// 修改密码时新密码必填提示 /// /// In zh, this message translates to: /// **'请输入新密码'** String get newPasswordRequired; /// 密码格式验证 /// /// In zh, this message translates to: /// **'密码需8-16位,包含大小写字母和数字'** String get passwordFormatError; /// 修改密码时确认密码标题 /// /// In zh, this message translates to: /// **'再次确认密码'** String get confirmPassword; /// 修改密码时确认密码必填提示 /// /// In zh, this message translates to: /// **'请再次确认密码'** String get confirmPasswordRequired; /// 修改密码时确认密码不一致提示 /// /// In zh, this message translates to: /// **'两次密码不一致'** String get confirmPasswordError; /// 确定按钮文本 /// /// In zh, this message translates to: /// **'确定'** String get confirm; /// 取消按钮文本 /// /// In zh, this message translates to: /// **'取消'** String get cancel; /// 记住密码选项 /// /// In zh, this message translates to: /// **'记住密码'** String get rememberPassword; } class _AppLocalizationsDelegate extends LocalizationsDelegate { const _AppLocalizationsDelegate(); @override Future load(Locale locale) { return SynchronousFuture(lookupAppLocalizations(locale)); } @override bool isSupported(Locale locale) => ['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.', ); }