网站怎么放404页面,网站建设搜索,首码项目网,佛山建站https://blog.csdn.net/eyupaopao/article/details/120090431 resx资源文件实现 resx资源文件#xff0c;实现的过程比第一种复杂#xff0c;但resx文件本身编辑比较简单#xff0c;维护起来比较方便。需要用到的框架#xff1a;WpfExtensions.Xaml
为每种语言添加.resx资…https://blog.csdn.net/eyupaopao/article/details/120090431 resx资源文件实现 resx资源文件实现的过程比第一种复杂但resx文件本身编辑比较简单维护起来比较方便。需要用到的框架WpfExtensions.Xaml
为每种语言添加.resx资源文件放在I18nResource文件夹下 I18nResource.resx 代表英语名字不要改 I18nResource.zh-CN.resx 代表中文 国家简写 创建完I18nResource.resx文件后会生成一个I18nResource.Designer.cs文件添加一个I18nProvider.tt文件与资源文件放在同一个文件夹visual studio会自动解析这个文件并扫描resx资源文件并生成一个I18nProvider.cs文件代码
# template debugfalse hostspecifictrue languageC# #
# assembly nameSystem.Core #
# assembly nameSystem.Xml #
# assembly nameSystem.Xml.Linq #
# import namespaceSystem.Linq #
# import namespaceSystem.Text #
# import namespaceSystem.Collections.Generic #
# import namespaceSystem.Xml.Linq #
# import namespaceSystem.IO #
# output extension.cs #using System.Windows;#const string ResourceFileName I18nResource.resx;
#namespace #System.Runtime.Remoting.Messaging.CallContext.LogicalGetData(NamespaceHint).ToString()#
{public static class I18nProvider{#var resourceKeys XElement.Load(this.Host.ResolvePath(ResourceFileName)).Elements(data).Select(item item.Attribute(name)?.Value).Where(item item ! null);var resourceDesignerName Path.GetFileNameWithoutExtension(ResourceFileName);foreach (string resourceKey in resourceKeys){
#public static readonly ComponentResourceKey # resourceKey # new ComponentResourceKey(typeof(# resourceDesignerName #), nameof(# resourceDesignerName #.# resourceKey #));
#}
#}
}