app_localizations.dart 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. import 'dart:async';
  2. import 'package:flutter/foundation.dart';
  3. import 'package:flutter/widgets.dart';
  4. import 'package:flutter_localizations/flutter_localizations.dart';
  5. import 'package:intl/intl.dart' as intl;
  6. import 'app_localizations_zh.dart';
  7. // ignore_for_file: type=lint
  8. /// Callers can lookup localized strings with an instance of AppLocalizations
  9. /// returned by `AppLocalizations.of(context)`.
  10. ///
  11. /// Applications need to include `AppLocalizations.delegate()` in their app's
  12. /// `localizationDelegates` list, and the locales they support in the app's
  13. /// `supportedLocales` list. For example:
  14. ///
  15. /// ```dart
  16. /// import 'l10n/app_localizations.dart';
  17. ///
  18. /// return MaterialApp(
  19. /// localizationsDelegates: AppLocalizations.localizationsDelegates,
  20. /// supportedLocales: AppLocalizations.supportedLocales,
  21. /// home: MyApplicationHome(),
  22. /// );
  23. /// ```
  24. ///
  25. /// ## Update pubspec.yaml
  26. ///
  27. /// Please make sure to update your pubspec.yaml to include the following
  28. /// packages:
  29. ///
  30. /// ```yaml
  31. /// dependencies:
  32. /// # Internationalization support.
  33. /// flutter_localizations:
  34. /// sdk: flutter
  35. /// intl: any # Use the pinned version from flutter_localizations
  36. ///
  37. /// # Rest of dependencies
  38. /// ```
  39. ///
  40. /// ## iOS Applications
  41. ///
  42. /// iOS applications define key application metadata, including supported
  43. /// locales, in an Info.plist file that is built into the application bundle.
  44. /// To configure the locales supported by your app, you’ll need to edit this
  45. /// file.
  46. ///
  47. /// First, open your project’s ios/Runner.xcworkspace Xcode workspace file.
  48. /// Then, in the Project Navigator, open the Info.plist file under the Runner
  49. /// project’s Runner folder.
  50. ///
  51. /// Next, select the Information Property List item, select Add Item from the
  52. /// Editor menu, then select Localizations from the pop-up menu.
  53. ///
  54. /// Select and expand the newly-created Localizations item then, for each
  55. /// locale your application supports, add a new item and select the locale
  56. /// you wish to add from the pop-up menu in the Value field. This list should
  57. /// be consistent with the languages listed in the AppLocalizations.supportedLocales
  58. /// property.
  59. abstract class AppLocalizations {
  60. AppLocalizations(String locale)
  61. : localeName = intl.Intl.canonicalizedLocale(locale.toString());
  62. final String localeName;
  63. static AppLocalizations? of(BuildContext context) {
  64. return Localizations.of<AppLocalizations>(context, AppLocalizations);
  65. }
  66. static const LocalizationsDelegate<AppLocalizations> delegate =
  67. _AppLocalizationsDelegate();
  68. /// A list of this localizations delegate along with the default localizations
  69. /// delegates.
  70. ///
  71. /// Returns a list of localizations delegates containing this delegate along with
  72. /// GlobalMaterialLocalizations.delegate, GlobalCupertinoLocalizations.delegate,
  73. /// and GlobalWidgetsLocalizations.delegate.
  74. ///
  75. /// Additional delegates can be added by appending to this list in
  76. /// MaterialApp. This list does not have to be used at all if a custom list
  77. /// of delegates is preferred or required.
  78. static const List<LocalizationsDelegate<dynamic>> localizationsDelegates =
  79. <LocalizationsDelegate<dynamic>>[
  80. delegate,
  81. GlobalMaterialLocalizations.delegate,
  82. GlobalCupertinoLocalizations.delegate,
  83. GlobalWidgetsLocalizations.delegate,
  84. ];
  85. /// A list of this localizations delegate's supported locales.
  86. static const List<Locale> supportedLocales = <Locale>[Locale('zh')];
  87. /// 应用名称
  88. ///
  89. /// In zh, this message translates to:
  90. /// **'SinoMed Cloud'**
  91. String get appName;
  92. /// 应用副标题
  93. ///
  94. /// In zh, this message translates to:
  95. /// **'中方诊药云'**
  96. String get appSubtitle;
  97. /// 密码登录标签
  98. ///
  99. /// In zh, this message translates to:
  100. /// **'密码登录'**
  101. String get passwordLogin;
  102. /// 验证码登录标签
  103. ///
  104. /// In zh, this message translates to:
  105. /// **'验证码登录'**
  106. String get smsLogin;
  107. /// 手机号标签
  108. ///
  109. /// In zh, this message translates to:
  110. /// **'手机号'**
  111. String get phoneNumber;
  112. /// 手机号输入提示
  113. ///
  114. /// In zh, this message translates to:
  115. /// **'请输入手机号'**
  116. String get phoneNumberHint;
  117. /// 手机号必填验证
  118. ///
  119. /// In zh, this message translates to:
  120. /// **'请输入手机号'**
  121. String get phoneNumberRequired;
  122. /// 手机号格式验证
  123. ///
  124. /// In zh, this message translates to:
  125. /// **'请输入正确的手机号'**
  126. String get phoneNumberInvalid;
  127. /// 密码标签
  128. ///
  129. /// In zh, this message translates to:
  130. /// **'密码'**
  131. String get password;
  132. /// 密码输入提示
  133. ///
  134. /// In zh, this message translates to:
  135. /// **'请输入密码'**
  136. String get passwordHint;
  137. /// 密码必填验证
  138. ///
  139. /// In zh, this message translates to:
  140. /// **'请输入密码'**
  141. String get passwordRequired;
  142. /// 密码长度验证
  143. ///
  144. /// In zh, this message translates to:
  145. /// **'密码长度不能少于6位'**
  146. String get passwordMinLength;
  147. /// 忘记密码链接
  148. ///
  149. /// In zh, this message translates to:
  150. /// **'忘记密码?'**
  151. String get forgotPassword;
  152. /// 忘记密码功能提示
  153. ///
  154. /// In zh, this message translates to:
  155. /// **'忘记密码功能待实现'**
  156. String get forgotPasswordNotImplemented;
  157. /// 登录按钮
  158. ///
  159. /// In zh, this message translates to:
  160. /// **'登录'**
  161. String get login;
  162. /// 退出登录按钮
  163. ///
  164. /// In zh, this message translates to:
  165. /// **'退出登录'**
  166. String get logout;
  167. /// 登录功能提示
  168. ///
  169. /// In zh, this message translates to:
  170. /// **'登录功能待实现'**
  171. String get loginNotImplemented;
  172. /// 验证码标签
  173. ///
  174. /// In zh, this message translates to:
  175. /// **'验证码'**
  176. String get smsCode;
  177. /// 验证码输入提示
  178. ///
  179. /// In zh, this message translates to:
  180. /// **'请输入验证码'**
  181. String get smsCodeHint;
  182. /// 验证码必填验证
  183. ///
  184. /// In zh, this message translates to:
  185. /// **'请输入验证码'**
  186. String get smsCodeRequired;
  187. /// 验证码长度验证
  188. ///
  189. /// In zh, this message translates to:
  190. /// **'验证码为4位数字'**
  191. String get smsCodeLength;
  192. /// 验证码格式验证
  193. ///
  194. /// In zh, this message translates to:
  195. /// **'验证码格式不正确'**
  196. String get smsCodeInvalid;
  197. /// 验证码已过期或未获取提示
  198. ///
  199. /// In zh, this message translates to:
  200. /// **'请获取验证码'**
  201. String get smsCodeExpired;
  202. /// 验证码过期提示
  203. ///
  204. /// In zh, this message translates to:
  205. /// **'验证码已过期'**
  206. String get smsCodeHasExpired;
  207. /// 验证码输入错误提示
  208. ///
  209. /// In zh, this message translates to:
  210. /// **'验证码错误'**
  211. String get smsCodeError;
  212. /// 获取验证码按钮
  213. ///
  214. /// In zh, this message translates to:
  215. /// **'获取验证码'**
  216. String get getSmsCode;
  217. /// 重新获取验证码按钮文本
  218. ///
  219. /// In zh, this message translates to:
  220. /// **'请重新获取验证码'**
  221. String get resendSmsCode;
  222. /// 验证码倒计时
  223. ///
  224. /// In zh, this message translates to:
  225. /// **'{count}秒'**
  226. String smsCodeCountdown(int count);
  227. /// 发送验证码时手机号必填提示
  228. ///
  229. /// In zh, this message translates to:
  230. /// **'请输入手机号'**
  231. String get phoneNumberRequiredForSms;
  232. }
  233. class _AppLocalizationsDelegate
  234. extends LocalizationsDelegate<AppLocalizations> {
  235. const _AppLocalizationsDelegate();
  236. @override
  237. Future<AppLocalizations> load(Locale locale) {
  238. return SynchronousFuture<AppLocalizations>(lookupAppLocalizations(locale));
  239. }
  240. @override
  241. bool isSupported(Locale locale) =>
  242. <String>['zh'].contains(locale.languageCode);
  243. @override
  244. bool shouldReload(_AppLocalizationsDelegate old) => false;
  245. }
  246. AppLocalizations lookupAppLocalizations(Locale locale) {
  247. // Lookup logic when only language code is specified.
  248. switch (locale.languageCode) {
  249. case 'zh':
  250. return AppLocalizationsZh();
  251. }
  252. throw FlutterError(
  253. 'AppLocalizations.delegate failed to load unsupported locale "$locale". This is likely '
  254. 'an issue with the localizations generation tool. Please file an issue '
  255. 'on GitHub with a reproducible sample app and the gen-l10n configuration '
  256. 'that was used.');
  257. }