在程序中支持多语言环境,支持asp.net和winform。
2006-04-27 18:34
381 查看
图一, 资源文件结构
根据上面的资源文件结构,在程序中调用资源选项应该是:control.Text = Resources.MultiString.SR.XXX。
XXX返回的是哪种语言将根据你定义的地区语言环境相关。
图二, 设置该项的编译选项为”stringresourcetool”
图三, 手工运行string resource tool
理论上只要按照图二设置了之后,编译工程时将自动编译这些资源文件。
以下是资源文件的选项说明
# 本文件用于产生 SR.cs 和 SR.resx 文件.
#
# 注意:如果你使用非ASCII字符,文件应该用UTF8编码格式保存. This can be achieved by right clicking
# over the file in the solution explorer, select Open With -> Text Editor (with Encoding )
# Select Unicode (UTF-8 with Signature), and save.
#
# "#!" 表示处理文件的选项
# ";" 或 "#"表示注释
# 定义SR类为public类型,而不是internal(缺省),请使用如下选项:
##! accessor_class_accessibility = public
# To specify a static property that will be used to select the appropriate
# culture for the resources, e.g. Thread.CurrentUICulture, or CultureInfo.Neutral
# to always pick the neutral culture, or a custom class.
##! culture_info = Resources.CultureInfo
# 针对此项资源文件不产生类(如第二个,第三个。。资源文件),则添加如下选项:
##! generate_class = false
# If this file has a Custom Tool Namespace set, then the tool cannot obtain
# the correct namespace that the resources will be compiled into. In this case
# it is necessary to specify the resrouce namespace. This can be worked out
# by compiling the assembly, then opening in Reflector, and looking at the resources.
#
# For VB.NET the resource namespace will always be the Root Namespace of the project.
#
# For C# the resource namespace will be (For a .strings file nested in two folders):
# <DefaultNamespace>.<FirstFolder>.<SecondFolder>
# e.g. ProjectDir\Resources\Custom\SR.strings
# => <DefaultNamespace>.Resources.Custom
#
##! resource_namespace = RootNamespace
# 在每个资源文件中必须声明此资源文件代表的语言
# [strings{.locale}]
#
# e.g.
# [strings]
# [strings.de]
# [strings.de-DE]
# [strings.de-CK]
#
#示例:缺省资源项,对应的资源文件将用于产生类,因此此资源文件必须包含所有的资源项。
[strings]
Raw = Raw string
WithArgs(a,b) = First argument {0}, Second argument {1}
WithTypedArgs(int a, string b) = Integer arg {0}, string arg {2}
MultiLine(c,d) = First Line {0}
= Second Line {1}
# 中文资源文件
[strings.zh-CN]
Raw = 中文
源代码下载:http://files.cnblogs.com/margiex/SRResourceGenerator_v2.rar
打开SRResourceGenerator\SRGenerator.CustomTool\SRResourceGenerator.sln 工程,格式是vs2005的,网上其它地方的格式是.net 1.1的。
在vs2005中编译后有install选项,如果在vs2005中不能”run custom tool”,请打开srgencode.reg文件,根据你的安装路径重新设置后合并此文件的内容到注册表。
引用
工程地址
http://projectdistributor.readify.net/Projects/Project.aspx?projectId=2
示例地址
http://projectdistributor.readify.net/Releases/Release.aspx?releaseId=10
根据上面的资源文件结构,在程序中调用资源选项应该是:control.Text = Resources.MultiString.SR.XXX。
XXX返回的是哪种语言将根据你定义的地区语言环境相关。
图二, 设置该项的编译选项为”stringresourcetool”
图三, 手工运行string resource tool
理论上只要按照图二设置了之后,编译工程时将自动编译这些资源文件。
以下是资源文件的选项说明
# 本文件用于产生 SR.cs 和 SR.resx 文件.
#
# 注意:如果你使用非ASCII字符,文件应该用UTF8编码格式保存. This can be achieved by right clicking
# over the file in the solution explorer, select Open With -> Text Editor (with Encoding )
# Select Unicode (UTF-8 with Signature), and save.
#
# "#!" 表示处理文件的选项
# ";" 或 "#"表示注释
# 定义SR类为public类型,而不是internal(缺省),请使用如下选项:
##! accessor_class_accessibility = public
# To specify a static property that will be used to select the appropriate
# culture for the resources, e.g. Thread.CurrentUICulture, or CultureInfo.Neutral
# to always pick the neutral culture, or a custom class.
##! culture_info = Resources.CultureInfo
# 针对此项资源文件不产生类(如第二个,第三个。。资源文件),则添加如下选项:
##! generate_class = false
# If this file has a Custom Tool Namespace set, then the tool cannot obtain
# the correct namespace that the resources will be compiled into. In this case
# it is necessary to specify the resrouce namespace. This can be worked out
# by compiling the assembly, then opening in Reflector, and looking at the resources.
#
# For VB.NET the resource namespace will always be the Root Namespace of the project.
#
# For C# the resource namespace will be (For a .strings file nested in two folders):
# <DefaultNamespace>.<FirstFolder>.<SecondFolder>
# e.g. ProjectDir\Resources\Custom\SR.strings
# => <DefaultNamespace>.Resources.Custom
#
##! resource_namespace = RootNamespace
# 在每个资源文件中必须声明此资源文件代表的语言
# [strings{.locale}]
#
# e.g.
# [strings]
# [strings.de]
# [strings.de-DE]
# [strings.de-CK]
#
#示例:缺省资源项,对应的资源文件将用于产生类,因此此资源文件必须包含所有的资源项。
[strings]
Raw = Raw string
WithArgs(a,b) = First argument {0}, Second argument {1}
WithTypedArgs(int a, string b) = Integer arg {0}, string arg {2}
MultiLine(c,d) = First Line {0}
= Second Line {1}
# 中文资源文件
[strings.zh-CN]
Raw = 中文
源代码下载:http://files.cnblogs.com/margiex/SRResourceGenerator_v2.rar
打开SRResourceGenerator\SRGenerator.CustomTool\SRResourceGenerator.sln 工程,格式是vs2005的,网上其它地方的格式是.net 1.1的。
在vs2005中编译后有install选项,如果在vs2005中不能”run custom tool”,请打开srgencode.reg文件,根据你的安装路径重新设置后合并此文件的内容到注册表。
引用
工程地址
http://projectdistributor.readify.net/Projects/Project.aspx?projectId=2
示例地址
http://projectdistributor.readify.net/Releases/Release.aspx?releaseId=10
相关文章推荐
- 晚上无聊象征性收取了网友100元辛苦费,实现支持多语言功能的XML语言包版的C#的ASP.NET多语言支持例子程序
- 晚上无聊象征性收取了网友100元辛苦费,实现支持多语言功能的XML语言包版的C#的ASP.NET多语言支持例子程序
- 晚上无聊象征性收取了网友100元辛苦费,实现支持多语言功能的XML语言包版的C#的ASP.NET多语言支持例子程序
- 晚上无聊象征性收取了网友100元辛苦费,实现支持多语言功能的XML语言包版的C#的ASP.NET多语言支持例子程序
- 晚上无聊象征性收取了网友100元辛苦费,实现支持多语言功能的XML语言包版的C#的ASP.NET多语言支持例子程序
- 晚上无聊象征性收取了网友100元辛苦费,实现支持多语言功能的XML语言包版的C#的ASP.NET多语言支持例子程序
- 晚上无聊象征性收取了网友100元辛苦费,实现支持多语言功能的XML语言包版的C#的ASP.NET多语言支持例子程序
- 晚上无聊象征性收取了网友100元辛苦费,实现支持多语言功能的XML语言包版的C#的ASP.NET多语言支持例子程序
- 晚上无聊象征性收取了网友100元辛苦费,实现支持多语言功能的XML语言包版的C#的ASP.NET多语言支持例子程序
- 晚上无聊象征性收取了网友100元辛苦费,实现支持多语言功能的XML语言包版的C#的ASP.NET多语言支持例子程序
- 晚上无聊象征性收取了网友100元辛苦费,实现支持多语言功能的XML语言包版的C#的ASP.NET多语言支持例子程序
- 在WinForm程序中嵌入ASP.NET
- ASP.NET程序也能像WinForm程序一样运行[转载]
- ASP.NET国际化(多语言)支持组件[提供下载]
- asp.net 4.0 IIS7.0/7.5环境提供了自动预热功能(程序池自动重启)
- 使用 根据语言环境不同 而显示不同的 资源本地化 ASP.NET 网页
- 在Winform,Silvelight,WPF等程序中访问Asp.net MVC web api
- 使用微软asp.net语言开发wap网站程序和大部分手机更具兼容性
- ASP.NET 网站支持多语言
- .Net中导出数据到Excel(asp.net和winform程序中)