app_localizations.dart 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  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_en.dart';
  7. import 'app_localizations_zh.dart';
  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 'generated/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) : localeName = intl.Intl.canonicalizedLocale(locale.toString());
  61. final String localeName;
  62. static AppLocalizations? of(BuildContext context) {
  63. return Localizations.of<AppLocalizations>(context, AppLocalizations);
  64. }
  65. static const LocalizationsDelegate<AppLocalizations> delegate = _AppLocalizationsDelegate();
  66. /// A list of this localizations delegate along with the default localizations
  67. /// delegates.
  68. ///
  69. /// Returns a list of localizations delegates containing this delegate along with
  70. /// GlobalMaterialLocalizations.delegate, GlobalCupertinoLocalizations.delegate,
  71. /// and GlobalWidgetsLocalizations.delegate.
  72. ///
  73. /// Additional delegates can be added by appending to this list in
  74. /// MaterialApp. This list does not have to be used at all if a custom list
  75. /// of delegates is preferred or required.
  76. static const List<LocalizationsDelegate<dynamic>> localizationsDelegates = <LocalizationsDelegate<dynamic>>[
  77. delegate,
  78. GlobalMaterialLocalizations.delegate,
  79. GlobalCupertinoLocalizations.delegate,
  80. GlobalWidgetsLocalizations.delegate,
  81. ];
  82. /// A list of this localizations delegate's supported locales.
  83. static const List<Locale> supportedLocales = <Locale>[
  84. Locale('en'),
  85. Locale('zh')
  86. ];
  87. /// No description provided for @appTitle.
  88. ///
  89. /// In en, this message translates to:
  90. /// **'Chinese Chess'**
  91. String get appTitle;
  92. /// No description provided for @menu.
  93. ///
  94. /// In en, this message translates to:
  95. /// **'Menu'**
  96. String get menu;
  97. /// No description provided for @openMenu.
  98. ///
  99. /// In en, this message translates to:
  100. /// **'Open Menu'**
  101. String get openMenu;
  102. /// No description provided for @flipBoard.
  103. ///
  104. /// In en, this message translates to:
  105. /// **'Flip Board'**
  106. String get flipBoard;
  107. /// No description provided for @copyCode.
  108. ///
  109. /// In en, this message translates to:
  110. /// **'Copy Chess Code'**
  111. String get copyCode;
  112. /// No description provided for @parseCode.
  113. ///
  114. /// In en, this message translates to:
  115. /// **'Parse Chess Code'**
  116. String get parseCode;
  117. /// No description provided for @editCode.
  118. ///
  119. /// In en, this message translates to:
  120. /// **'Edit Chess'**
  121. String get editCode;
  122. /// No description provided for @newGame.
  123. ///
  124. /// In en, this message translates to:
  125. /// **'New Game'**
  126. String get newGame;
  127. /// No description provided for @loadManual.
  128. ///
  129. /// In en, this message translates to:
  130. /// **'Load Chess Manual'**
  131. String get loadManual;
  132. /// No description provided for @saveManual.
  133. ///
  134. /// In en, this message translates to:
  135. /// **'Save Chess Manual'**
  136. String get saveManual;
  137. /// No description provided for @setting.
  138. ///
  139. /// In en, this message translates to:
  140. /// **'Setting'**
  141. String get setting;
  142. /// No description provided for @featureNotAvailable.
  143. ///
  144. /// In en, this message translates to:
  145. /// **'Feature is not available'**
  146. String get featureNotAvailable;
  147. /// No description provided for @modeRobot.
  148. ///
  149. /// In en, this message translates to:
  150. /// **'Robot Mode'**
  151. String get modeRobot;
  152. /// No description provided for @modeOnline.
  153. ///
  154. /// In en, this message translates to:
  155. /// **'Online Mode'**
  156. String get modeOnline;
  157. /// No description provided for @modeFree.
  158. ///
  159. /// In en, this message translates to:
  160. /// **'Free Mode'**
  161. String get modeFree;
  162. /// No description provided for @clearAll.
  163. ///
  164. /// In en, this message translates to:
  165. /// **'Clear All'**
  166. String get clearAll;
  167. /// No description provided for @save.
  168. ///
  169. /// In en, this message translates to:
  170. /// **'Apply'**
  171. String get save;
  172. /// No description provided for @trusteeshipToRobots.
  173. ///
  174. /// In en, this message translates to:
  175. /// **'Trusteeship to Robots'**
  176. String get trusteeshipToRobots;
  177. /// No description provided for @cancelRobots.
  178. ///
  179. /// In en, this message translates to:
  180. /// **'Cancel Trusteeship'**
  181. String get cancelRobots;
  182. /// No description provided for @thinking.
  183. ///
  184. /// In en, this message translates to:
  185. /// **'Thinking...'**
  186. String get thinking;
  187. /// No description provided for @currentInfo.
  188. ///
  189. /// In en, this message translates to:
  190. /// **'Current'**
  191. String get currentInfo;
  192. /// No description provided for @manual.
  193. ///
  194. /// In en, this message translates to:
  195. /// **'Manual'**
  196. String get manual;
  197. /// No description provided for @theEvent.
  198. ///
  199. /// In en, this message translates to:
  200. /// **'Event: '**
  201. String get theEvent;
  202. /// No description provided for @theSite.
  203. ///
  204. /// In en, this message translates to:
  205. /// **'Site: '**
  206. String get theSite;
  207. /// No description provided for @theDate.
  208. ///
  209. /// In en, this message translates to:
  210. /// **'Date: '**
  211. String get theDate;
  212. /// No description provided for @theRound.
  213. ///
  214. /// In en, this message translates to:
  215. /// **'Round: '**
  216. String get theRound;
  217. /// No description provided for @theRed.
  218. ///
  219. /// In en, this message translates to:
  220. /// **'Red: '**
  221. String get theRed;
  222. /// No description provided for @theBlack.
  223. ///
  224. /// In en, this message translates to:
  225. /// **'Black: '**
  226. String get theBlack;
  227. /// No description provided for @stepStart.
  228. ///
  229. /// In en, this message translates to:
  230. /// **'==Start=='**
  231. String get stepStart;
  232. /// No description provided for @exitNow.
  233. ///
  234. /// In en, this message translates to:
  235. /// **'Exit Now ?'**
  236. String get exitNow;
  237. /// No description provided for @dontExit.
  238. ///
  239. /// In en, this message translates to:
  240. /// **'Wait a moment'**
  241. String get dontExit;
  242. /// No description provided for @yesExit.
  243. ///
  244. /// In en, this message translates to:
  245. /// **'Yes exit'**
  246. String get yesExit;
  247. /// No description provided for @clickAgainToExit.
  248. ///
  249. /// In en, this message translates to:
  250. /// **'Click again to Exit'**
  251. String get clickAgainToExit;
  252. /// No description provided for @apply.
  253. ///
  254. /// In en, this message translates to:
  255. /// **'Apply'**
  256. String get apply;
  257. /// No description provided for @situationCode.
  258. ///
  259. /// In en, this message translates to:
  260. /// **'Chess Code'**
  261. String get situationCode;
  262. /// No description provided for @invalidCode.
  263. ///
  264. /// In en, this message translates to:
  265. /// **'Invalid Chess Code'**
  266. String get invalidCode;
  267. /// No description provided for @copySuccess.
  268. ///
  269. /// In en, this message translates to:
  270. /// **'Copy Success'**
  271. String get copySuccess;
  272. /// No description provided for @saveSuccess.
  273. ///
  274. /// In en, this message translates to:
  275. /// **'Save Success'**
  276. String get saveSuccess;
  277. /// No description provided for @selectDirectorySave.
  278. ///
  279. /// In en, this message translates to:
  280. /// **'Select a Directory to Save'**
  281. String get selectDirectorySave;
  282. /// No description provided for @saveFilename.
  283. ///
  284. /// In en, this message translates to:
  285. /// **'Filename to Save'**
  286. String get saveFilename;
  287. /// No description provided for @selectPgnFile.
  288. ///
  289. /// In en, this message translates to:
  290. /// **'Select .PGN file'**
  291. String get selectPgnFile;
  292. /// No description provided for @recommendMove.
  293. ///
  294. /// In en, this message translates to:
  295. /// **'Recommend Move'**
  296. String get recommendMove;
  297. /// No description provided for @remark.
  298. ///
  299. /// In en, this message translates to:
  300. /// **'Remark'**
  301. String get remark;
  302. /// No description provided for @noRemark.
  303. ///
  304. /// In en, this message translates to:
  305. /// **'No remark'**
  306. String get noRemark;
  307. /// No description provided for @check.
  308. ///
  309. /// In en, this message translates to:
  310. /// **'Check'**
  311. String get check;
  312. /// No description provided for @checkmate.
  313. ///
  314. /// In en, this message translates to:
  315. /// **'Checkmate'**
  316. String get checkmate;
  317. /// No description provided for @longRecheckLoose.
  318. ///
  319. /// In en, this message translates to:
  320. /// **'The same move 3 round to Lose'**
  321. String get longRecheckLoose;
  322. /// No description provided for @noEatToDraw.
  323. ///
  324. /// In en, this message translates to:
  325. /// **'60 round with no eat to Draw'**
  326. String get noEatToDraw;
  327. /// No description provided for @trapped.
  328. ///
  329. /// In en, this message translates to:
  330. /// **'Checkmate'**
  331. String get trapped;
  332. /// No description provided for @redLoose.
  333. ///
  334. /// In en, this message translates to:
  335. /// **'Loose'**
  336. String get redLoose;
  337. /// No description provided for @redWin.
  338. ///
  339. /// In en, this message translates to:
  340. /// **'Win'**
  341. String get redWin;
  342. /// No description provided for @redDraw.
  343. ///
  344. /// In en, this message translates to:
  345. /// **'Draw'**
  346. String get redDraw;
  347. /// No description provided for @requestDraw.
  348. ///
  349. /// In en, this message translates to:
  350. /// **'Asked for a draw'**
  351. String get requestDraw;
  352. /// No description provided for @agreeToDraw.
  353. ///
  354. /// In en, this message translates to:
  355. /// **'Agree to draw'**
  356. String get agreeToDraw;
  357. /// No description provided for @requestRetract.
  358. ///
  359. /// In en, this message translates to:
  360. /// **'Asked for a Retract'**
  361. String get requestRetract;
  362. /// No description provided for @agreeRetract.
  363. ///
  364. /// In en, this message translates to:
  365. /// **'Agree to retract'**
  366. String get agreeRetract;
  367. /// No description provided for @disagreeRetract.
  368. ///
  369. /// In en, this message translates to:
  370. /// **'Disagree to retract'**
  371. String get disagreeRetract;
  372. /// No description provided for @cantSendCheck.
  373. ///
  374. /// In en, this message translates to:
  375. /// **'You can\'t send Check'**
  376. String get cantSendCheck;
  377. /// No description provided for @plsParryCheck.
  378. ///
  379. /// In en, this message translates to:
  380. /// **'Please parry the Check'**
  381. String get plsParryCheck;
  382. /// No description provided for @oneMoreGame.
  383. ///
  384. /// In en, this message translates to:
  385. /// **'New Game'**
  386. String get oneMoreGame;
  387. /// No description provided for @letMeSee.
  388. ///
  389. /// In en, this message translates to:
  390. /// **'Not now'**
  391. String get letMeSee;
  392. /// No description provided for @settingTitle.
  393. ///
  394. /// In en, this message translates to:
  395. /// **'Settings'**
  396. String get settingTitle;
  397. }
  398. class _AppLocalizationsDelegate extends LocalizationsDelegate<AppLocalizations> {
  399. const _AppLocalizationsDelegate();
  400. @override
  401. Future<AppLocalizations> load(Locale locale) {
  402. return SynchronousFuture<AppLocalizations>(lookupAppLocalizations(locale));
  403. }
  404. @override
  405. bool isSupported(Locale locale) => <String>['en', 'zh'].contains(locale.languageCode);
  406. @override
  407. bool shouldReload(_AppLocalizationsDelegate old) => false;
  408. }
  409. AppLocalizations lookupAppLocalizations(Locale locale) {
  410. // Lookup logic when only language code is specified.
  411. switch (locale.languageCode) {
  412. case 'en': return AppLocalizationsEn();
  413. case 'zh': return AppLocalizationsZh();
  414. }
  415. throw FlutterError(
  416. 'AppLocalizations.delegate failed to load unsupported locale "$locale". This is likely '
  417. 'an issue with the localizations generation tool. Please file an issue '
  418. 'on GitHub with a reproducible sample app and the gen-l10n configuration '
  419. 'that was used.'
  420. );
  421. }