参考:Localization
现在 Core 项目的 XxxLocalizationConfigurer 内添加简体中文:
public static void Configure(ILocalizationConfiguration localizationConfiguration)
{
localizationConfiguration.Languages.Add(new LanguageInfo("en", "English", "famfamfam-flags england", isDefault: true));
localizationConfiguration.Languages.Add(new LanguageInfo("tr", "Türkçe", "famfamfam-flags tr"));
localizationConfiguration.Languages.Add(new LanguageInfo("zh-CN", "简体中文", "famfamfam-flags cn"));
localizationConfiguration.Sources.Add(
new DictionaryBasedLocalizationSource(SimpleTaskSystemConsts.LocalizationSourceName,
new JsonEmbeddedFileLocalizationDictionaryProvider(
typeof(SimpleTaskSystemLocalizationConfigurer).GetAssembly(),
"SimpleTaskSystem.Localization.SourceFiles"
)
)
);
}
然后在 SourceFiles 文件夹下创建 Xxx-zh-CN.json:
{
"culture": "zh-CN",
"texts": {
"HelloWorld": "你好",
"ChangeLanguage": "语言设置",
"HomePage": "主页",
"About": "关于",
"Home_Description": "主页",
"About_Description": "关于",
"TaskList": "任务清单",
"TaskState_Open": "进行中",
"TaskState_Completed": "已完成"
}
}
然后将该 JSON 文件的生成操作修改为“嵌入的资源”:
最后编译 Core 项目,重启前台项目即可。