changeLanguage method
切换语言,如果是跟随系统,多语言下需要手动设置显示文案
Implementation
void changeLanguage(
String languageName, Function(Locale, LanguageVo) onSuccess,
{LanguageVo? def}) {
LanguageVo? languageVo = _langMap[languageName];
if (languageVo == null) {
if (def == null) {
languageVo = LanguageVo.toSystem();
} else {
languageVo = def;
}
}
LanguageVo lang = languageVo;
Locale locale = Locale(lang.languageCode, lang.countryCode);
onSuccess.call(locale, lang);
_langVo = lang;
KSpUtils.putT(_langKey, lang, (value) => lang.toJson());
}