多语言支持
This commit is contained in:
@@ -5,7 +5,18 @@ import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:intl/intl.dart' as intl;
|
||||
|
||||
import 'app_localizations_ar.dart';
|
||||
import 'app_localizations_de.dart';
|
||||
import 'app_localizations_en.dart';
|
||||
import 'app_localizations_es.dart';
|
||||
import 'app_localizations_fr.dart';
|
||||
import 'app_localizations_hi.dart';
|
||||
import 'app_localizations_id.dart';
|
||||
import 'app_localizations_it.dart';
|
||||
import 'app_localizations_ja.dart';
|
||||
import 'app_localizations_ko.dart';
|
||||
import 'app_localizations_pt.dart';
|
||||
import 'app_localizations_ru.dart';
|
||||
import 'app_localizations_zh.dart';
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
@@ -94,7 +105,18 @@ abstract class AppLocalizations {
|
||||
|
||||
/// A list of this localizations delegate's supported locales.
|
||||
static const List<Locale> supportedLocales = <Locale>[
|
||||
Locale('ar'),
|
||||
Locale('de'),
|
||||
Locale('en'),
|
||||
Locale('es'),
|
||||
Locale('fr'),
|
||||
Locale('hi'),
|
||||
Locale('id'),
|
||||
Locale('it'),
|
||||
Locale('ja'),
|
||||
Locale('ko'),
|
||||
Locale('pt'),
|
||||
Locale('ru'),
|
||||
Locale('zh'),
|
||||
];
|
||||
|
||||
@@ -275,7 +297,7 @@ abstract class AppLocalizations {
|
||||
/// No description provided for @sessions.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'{count, plural, =1{session} other{sessions}}'**
|
||||
/// **'{count, plural, =1{{count} session} other{{count} sessions}}'**
|
||||
String sessions(int count);
|
||||
|
||||
/// No description provided for @completed.
|
||||
@@ -550,6 +572,72 @@ abstract class AppLocalizations {
|
||||
/// In en, this message translates to:
|
||||
/// **'中文 (Chinese)'**
|
||||
String get chinese;
|
||||
|
||||
/// No description provided for @japanese.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'日本語 (Japanese)'**
|
||||
String get japanese;
|
||||
|
||||
/// No description provided for @korean.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'한국어 (Korean)'**
|
||||
String get korean;
|
||||
|
||||
/// No description provided for @spanish.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Español (Spanish)'**
|
||||
String get spanish;
|
||||
|
||||
/// No description provided for @german.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Deutsch (German)'**
|
||||
String get german;
|
||||
|
||||
/// No description provided for @french.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Français (French)'**
|
||||
String get french;
|
||||
|
||||
/// No description provided for @portuguese.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Português (Portuguese)'**
|
||||
String get portuguese;
|
||||
|
||||
/// No description provided for @russian.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Русский (Russian)'**
|
||||
String get russian;
|
||||
|
||||
/// No description provided for @hindi.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'हिन्दी (Hindi)'**
|
||||
String get hindi;
|
||||
|
||||
/// No description provided for @indonesian.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Bahasa Indonesia (Indonesian)'**
|
||||
String get indonesian;
|
||||
|
||||
/// No description provided for @italian.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Italiano (Italian)'**
|
||||
String get italian;
|
||||
|
||||
/// No description provided for @arabic.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'العربية (Arabic)'**
|
||||
String get arabic;
|
||||
}
|
||||
|
||||
class _AppLocalizationsDelegate
|
||||
@@ -562,8 +650,21 @@ class _AppLocalizationsDelegate
|
||||
}
|
||||
|
||||
@override
|
||||
bool isSupported(Locale locale) =>
|
||||
<String>['en', 'zh'].contains(locale.languageCode);
|
||||
bool isSupported(Locale locale) => <String>[
|
||||
'ar',
|
||||
'de',
|
||||
'en',
|
||||
'es',
|
||||
'fr',
|
||||
'hi',
|
||||
'id',
|
||||
'it',
|
||||
'ja',
|
||||
'ko',
|
||||
'pt',
|
||||
'ru',
|
||||
'zh',
|
||||
].contains(locale.languageCode);
|
||||
|
||||
@override
|
||||
bool shouldReload(_AppLocalizationsDelegate old) => false;
|
||||
@@ -572,8 +673,30 @@ class _AppLocalizationsDelegate
|
||||
AppLocalizations lookupAppLocalizations(Locale locale) {
|
||||
// Lookup logic when only language code is specified.
|
||||
switch (locale.languageCode) {
|
||||
case 'ar':
|
||||
return AppLocalizationsAr();
|
||||
case 'de':
|
||||
return AppLocalizationsDe();
|
||||
case 'en':
|
||||
return AppLocalizationsEn();
|
||||
case 'es':
|
||||
return AppLocalizationsEs();
|
||||
case 'fr':
|
||||
return AppLocalizationsFr();
|
||||
case 'hi':
|
||||
return AppLocalizationsHi();
|
||||
case 'id':
|
||||
return AppLocalizationsId();
|
||||
case 'it':
|
||||
return AppLocalizationsIt();
|
||||
case 'ja':
|
||||
return AppLocalizationsJa();
|
||||
case 'ko':
|
||||
return AppLocalizationsKo();
|
||||
case 'pt':
|
||||
return AppLocalizationsPt();
|
||||
case 'ru':
|
||||
return AppLocalizationsRu();
|
||||
case 'zh':
|
||||
return AppLocalizationsZh();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user