Flutter:并非所有本地化委托都支持应用程序的语言环境 [英] Flutter: Application's locale is not supported by all of its localization delegates
本文介绍了Flutter:并非所有本地化委托都支持应用程序的语言环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,我正在尝试在flutter应用程序中添加BottomNavigationBar,但是当我运行项目时出现错误:
Hello I am trying add BottomNavigationBar in flutter app but when i run project error occures :
A MaterialLocalizations delegate that supports the ka_GE locale was not found
这是我的应用程序代表:
This is my app delegates:
supportedLocales: [
const Locale('en', 'US'),
const Locale('ka', 'GE'),
const Locale('ru', 'RU'),
],
localizationsDelegates: [
const InfosLocalizationsDelegate(),
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate
],
locale: Locale('ka')
这是Custom LocalizationsDelegate:
This is Custom LocalizationsDelegate:
class CLocalizationsDelegate
extends LocalizationsDelegate<CLocalizations> {
const CLocalizationsDelegate();
@override
bool isSupported(Locale locale) =>
['en', 'ka', 'ru'].contains(locale.languageCode);
@override
Future<CLocalizations> load(Locale locale) async {
CLocalizations localizations = new CLocalizations(locale);
await localizations.load();
print("Load ${locale.languageCode}");
return localizations;
}
@override
bool shouldReload(CLocalizationsDelegate old) => false;
}
是的,我知道问题是'ka',因为MaterialLocalizations不支持该问题,但我必须解决该问题,所以伙计们可以帮我吗?
Yeah I know that the problem is 'ka' because MaterialLocalizations doesn't not supports it but I have to solve that problem, so guys can you help me out?
推荐答案
您可以实现自定义的MaterialLocalizations
委托
You can implement your custom MaterialLocalizations
delegate
class MaterialLocalizationKaDelegate extends LocalizationsDelegate<MaterialLocalizations> {
@override
bool isSupported(Locale locale) {
return locale.countryCode == "GE" && locale.languageCode == "ka";
}
@override
Future<MaterialLocalizations> load(Locale locale) async {
return MaterialLocalizationKa();
}
@override
bool shouldReload(Foo old) {
return false;
}
}
class MaterialLocalizationKa extends MaterialLocalizations {
// TODO: implement KA localization yourself
}
这篇关于Flutter:并非所有本地化委托都支持应用程序的语言环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文