i18n.dart 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. import 'dart:async';
  2. import 'package:flutter/foundation.dart';
  3. import 'package:flutter/material.dart';
  4. // ignore_for_file: non_constant_identifier_names
  5. // ignore_for_file: camel_case_types
  6. // ignore_for_file: prefer_single_quotes
  7. //This file is automatically generated. DO NOT EDIT, all your changes would be lost.
  8. class S implements WidgetsLocalizations {
  9. const S();
  10. static const GeneratedLocalizationsDelegate delegate =
  11. GeneratedLocalizationsDelegate();
  12. static S of(BuildContext context) => Localizations.of<S>(context, S);
  13. @override
  14. TextDirection get textDirection => TextDirection.ltr;
  15. String get cleans => "Cleans";
  16. String get level => "Level";
  17. String get next => "Next";
  18. String get pause_resume => "PAUSE/RESUME";
  19. String get points => "Points";
  20. String get reset => "RESET";
  21. String get reward => "Reward";
  22. String get sounds => "SOUNDS";
  23. }
  24. class $en extends S {
  25. const $en();
  26. }
  27. class $zh_CN extends S {
  28. const $zh_CN();
  29. @override
  30. TextDirection get textDirection => TextDirection.ltr;
  31. @override
  32. String get next => "下一个";
  33. @override
  34. String get reward => "赞赏";
  35. @override
  36. String get sounds => "声音";
  37. @override
  38. String get pause_resume => "暂停/恢复";
  39. @override
  40. String get level => "级别";
  41. @override
  42. String get reset => "重置";
  43. @override
  44. String get cleans => "消除";
  45. @override
  46. String get points => "分数";
  47. }
  48. class GeneratedLocalizationsDelegate extends LocalizationsDelegate<S> {
  49. const GeneratedLocalizationsDelegate();
  50. List<Locale> get supportedLocales {
  51. return const <Locale>[
  52. Locale("en", ""),
  53. Locale("zh", "CN"),
  54. ];
  55. }
  56. LocaleListResolutionCallback listResolution({Locale fallback}) {
  57. return (List<Locale> locales, Iterable<Locale> supported) {
  58. if (locales == null || locales.isEmpty) {
  59. return fallback ?? supported.first;
  60. } else {
  61. return _resolve(locales.first, fallback, supported);
  62. }
  63. };
  64. }
  65. LocaleResolutionCallback resolution({Locale fallback}) {
  66. return (Locale locale, Iterable<Locale> supported) {
  67. return _resolve(locale, fallback, supported);
  68. };
  69. }
  70. Locale _resolve(Locale locale, Locale fallback, Iterable<Locale> supported) {
  71. if (locale == null || !isSupported(locale)) {
  72. return fallback ?? supported.first;
  73. }
  74. final Locale languageLocale = Locale(locale.languageCode, "");
  75. if (supported.contains(locale)) {
  76. return locale;
  77. } else if (supported.contains(languageLocale)) {
  78. return languageLocale;
  79. } else {
  80. final Locale fallbackLocale = fallback ?? supported.first;
  81. return fallbackLocale;
  82. }
  83. }
  84. @override
  85. Future<S> load(Locale locale) {
  86. final String lang = getLang(locale);
  87. if (lang != null) {
  88. switch (lang) {
  89. case "en":
  90. return SynchronousFuture<S>(const $en());
  91. case "zh_CN":
  92. return SynchronousFuture<S>(const $zh_CN());
  93. default:
  94. // NO-OP.
  95. }
  96. }
  97. return SynchronousFuture<S>(const S());
  98. }
  99. @override
  100. bool isSupported(Locale locale) =>
  101. locale != null && supportedLocales.contains(locale);
  102. @override
  103. bool shouldReload(GeneratedLocalizationsDelegate old) => false;
  104. }
  105. String getLang(Locale l) => l == null
  106. ? null
  107. : l.countryCode != null && l.countryCode.isEmpty
  108. ? l.languageCode
  109. : l.toString();