| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- import 'package:e2ee_chat/common/global.dart';
- import 'package:flutter/foundation.dart';
- import 'package:flutter/material.dart';
- import 'package:intl/intl.dart';
- class GmLocalizations {
- static GmLocalizations of(BuildContext context) {
- return Localizations.of<GmLocalizations>(context, GmLocalizations) ?? GmLocalizations();
- }
- //TODO: Localizations
- String get title => Intl.message('MeChat', name: 'title');
- String get userName => Intl.message('Username', name: 'username');
- String get userNameOrEmail => Intl.message('Username or Email', name: 'username or email');
- String get userNameRequired => Intl.message('Username required', name: 'username required');
- String get password => Intl.message('Password', name: 'password');
- String get passwordRequired => Intl.message('PasswordRequired', name: 'password required');
- String get loading => Intl.message('Loading...', name: 'loading');
- String get userNameOrPasswordWrong => Intl.message('Username or password wrong', name: 'username or password wrong');
- String get home => Intl.message('Home', name: 'home');
- String get login => Intl.message('Login', name: 'login');
- String get logout => Intl.message('Logout', name: 'logout');
- String get language => Intl.message('Language', name: 'language');
- String get auto => Intl.message('Auto', name: 'auto');
- String get theme => Intl.message('Theme', name: 'theme');
- String get search => Intl.message('Search', name: 'search');
- String get searchUser => Intl.message('Find User', name: 'find user');
- String get addFriendFailed => Intl.message('Add friend failed', name: 'add friend failed');
- String get friendRequest => Intl.message('Friends Request', name: 'friend request');
- }
- //Locale代理类
- class GmLocalizationsDelegate extends LocalizationsDelegate<GmLocalizations> {
- const GmLocalizationsDelegate();
- //是否支持某个Local
- @override
- bool isSupported(Locale locale) => Global.locales.contains(locale.languageCode);
- // Flutter会调用此类加载相应的Locale资源类
- @override
- Future<GmLocalizations> load(Locale locale) {
- print("$locale");
- return SynchronousFuture<GmLocalizations>(
- GmLocalizations()
- );
- }
- // 当Localizations Widget重新build时,是否调用load重新加载Locale资源.
- @override
- bool shouldReload(GmLocalizationsDelegate old) => false;
- }
|