app_localizations.dart 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  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 phoneNumberRequired;
  117. /// 手机号格式验证
  118. ///
  119. /// In zh, this message translates to:
  120. /// **'请输入正确的手机号'**
  121. String get phoneNumberInvalid;
  122. /// 密码标签
  123. ///
  124. /// In zh, this message translates to:
  125. /// **'密码'**
  126. String get password;
  127. /// 密码输入提示/必填验证
  128. ///
  129. /// In zh, this message translates to:
  130. /// **'请输入密码'**
  131. String get passwordRequired;
  132. /// 密码长度验证
  133. ///
  134. /// In zh, this message translates to:
  135. /// **'密码长度不能少于6位'**
  136. String get passwordMinLength;
  137. /// 忘记密码链接
  138. ///
  139. /// In zh, this message translates to:
  140. /// **'忘记密码?'**
  141. String get forgotPassword;
  142. /// 忘记密码功能提示
  143. ///
  144. /// In zh, this message translates to:
  145. /// **'忘记密码功能待实现'**
  146. String get forgotPasswordNotImplemented;
  147. /// 登录按钮
  148. ///
  149. /// In zh, this message translates to:
  150. /// **'登录'**
  151. String get login;
  152. /// 退出登录按钮
  153. ///
  154. /// In zh, this message translates to:
  155. /// **'退出登录'**
  156. String get logout;
  157. /// 我的页面标题
  158. ///
  159. /// In zh, this message translates to:
  160. /// **'我的'**
  161. String get mine;
  162. /// 修改密码按钮
  163. ///
  164. /// In zh, this message translates to:
  165. /// **'修改密码'**
  166. String get changePassword;
  167. /// 修改密码成功提示
  168. ///
  169. /// In zh, this message translates to:
  170. /// **'修改密码成功'**
  171. String get changePasswordSuccess;
  172. /// 修改密码失败提示
  173. ///
  174. /// In zh, this message translates to:
  175. /// **'修改密码失败'**
  176. String get changePasswordFailed;
  177. /// 登录功能提示
  178. ///
  179. /// In zh, this message translates to:
  180. /// **'登录功能待实现'**
  181. String get loginNotImplemented;
  182. /// 验证码标签
  183. ///
  184. /// In zh, this message translates to:
  185. /// **'验证码'**
  186. String get smsCode;
  187. /// 验证码输入提示/必填验证
  188. ///
  189. /// In zh, this message translates to:
  190. /// **'请输入验证码'**
  191. String get smsCodeRequired;
  192. /// 验证码长度验证
  193. ///
  194. /// In zh, this message translates to:
  195. /// **'验证码为4位数字'**
  196. String get smsCodeLength;
  197. /// 验证码格式验证
  198. ///
  199. /// In zh, this message translates to:
  200. /// **'验证码格式不正确'**
  201. String get smsCodeInvalid;
  202. /// 验证码已过期或未获取提示
  203. ///
  204. /// In zh, this message translates to:
  205. /// **'请获取验证码'**
  206. String get smsCodeExpired;
  207. /// 验证码过期提示
  208. ///
  209. /// In zh, this message translates to:
  210. /// **'验证码已过期'**
  211. String get smsCodeHasExpired;
  212. /// 验证码输入错误提示
  213. ///
  214. /// In zh, this message translates to:
  215. /// **'验证码错误'**
  216. String get smsCodeError;
  217. /// 获取验证码按钮
  218. ///
  219. /// In zh, this message translates to:
  220. /// **'获取验证码'**
  221. String get getSmsCode;
  222. /// 验证码发送成功提示
  223. ///
  224. /// In zh, this message translates to:
  225. /// **'验证码已发送'**
  226. String get smsCodeSent;
  227. /// 重新获取验证码按钮文本
  228. ///
  229. /// In zh, this message translates to:
  230. /// **'请重新获取验证码'**
  231. String get resendSmsCode;
  232. /// 验证码倒计时
  233. ///
  234. /// In zh, this message translates to:
  235. /// **'{count}秒'**
  236. String smsCodeCountdown(int count);
  237. /// 输入新密码标题
  238. ///
  239. /// In zh, this message translates to:
  240. /// **'新密码'**
  241. String get newPassword;
  242. /// 修改密码时新密码必填提示
  243. ///
  244. /// In zh, this message translates to:
  245. /// **'请输入新密码'**
  246. String get newPasswordRequired;
  247. /// 密码格式验证
  248. ///
  249. /// In zh, this message translates to:
  250. /// **'密码需8-16位,包含大小写字母和数字'**
  251. String get passwordFormatError;
  252. /// 修改密码时确认密码标题
  253. ///
  254. /// In zh, this message translates to:
  255. /// **'再次确认密码'**
  256. String get confirmPassword;
  257. /// 修改密码时确认密码必填提示
  258. ///
  259. /// In zh, this message translates to:
  260. /// **'请再次确认密码'**
  261. String get confirmPasswordRequired;
  262. /// 修改密码时确认密码不一致提示
  263. ///
  264. /// In zh, this message translates to:
  265. /// **'两次密码不一致'**
  266. String get confirmPasswordError;
  267. /// 确定按钮文本
  268. ///
  269. /// In zh, this message translates to:
  270. /// **'确定'**
  271. String get confirm;
  272. /// 取消按钮文本
  273. ///
  274. /// In zh, this message translates to:
  275. /// **'取消'**
  276. String get cancel;
  277. }
  278. class _AppLocalizationsDelegate
  279. extends LocalizationsDelegate<AppLocalizations> {
  280. const _AppLocalizationsDelegate();
  281. @override
  282. Future<AppLocalizations> load(Locale locale) {
  283. return SynchronousFuture<AppLocalizations>(lookupAppLocalizations(locale));
  284. }
  285. @override
  286. bool isSupported(Locale locale) =>
  287. <String>['zh'].contains(locale.languageCode);
  288. @override
  289. bool shouldReload(_AppLocalizationsDelegate old) => false;
  290. }
  291. AppLocalizations lookupAppLocalizations(Locale locale) {
  292. // Lookup logic when only language code is specified.
  293. switch (locale.languageCode) {
  294. case 'zh':
  295. return AppLocalizationsZh();
  296. }
  297. throw FlutterError(
  298. 'AppLocalizations.delegate failed to load unsupported locale "$locale". This is likely '
  299. 'an issue with the localizations generation tool. Please file an issue '
  300. 'on GitHub with a reproducible sample app and the gen-l10n configuration '
  301. 'that was used.',
  302. );
  303. }