ABP项目的缺省语言是英文,如果需要将中文设置为缺省语言,需要在项目的StartUp中进行设置,代码如下:
public void Configure(IApplicationBuilder app)
{
//20201120 设置中文
app.ApplicationServices.GetService<ISettingDefinitionManager>().Get(LocalizationSettingNames.DefaultLanguage).DefaultValue = "zh-Hans";
app.InitializeApplication();
}
ABP项目缺省加载多种语言,如果只使用中文,就没有必要加载其它语言,并且界面上也不需要语言切换的功能,这种情况下,可以删除生成模板产生的语言加载代码,这些代码在模块的ConfigureLocalizationServices函数中:
private void ConfigureLocalizationServices()
{
Configure<AbpLocalizationOptions>(options =>
{
//options.Languages.Add(new LanguageInfo("ar", "ar", "العربية"));
//options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština"));
//options.Languages.Add(new LanguageInfo("en", "en", "English"));
//options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar"));
//options.Languages.Add(new LanguageInfo("fr", "fr", "Français"));
//options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português"));
//options.Languages.Add(new LanguageInfo("ru", "ru", "Русский"));
//options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe"));
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文"));
//options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文"));
});
}
网友评论