zoukankan      html  css  js  c++  java
  • 在程序中支持多语言环境,支持asp.net和winform。

    图一, 资源文件结构

     根据上面的资源文件结构,在程序中调用资源选项应该是: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 = 中文

     源代码下载:https://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 

  • 相关阅读:
    PHP抓取页面的几种方式
    MySQL性能优化的最佳20+条经验
    linux下导入、导出mysql数据库命令
    8个必备的PHP功能开发
    jquery中的children()和contents()的区别
    centos 通用开发工具及库安装 有了它不用愁了
    将bat批处理文件注册成windows服务
    squid隐藏squid的版本号
    squid如何屏蔽User-Agent为空的请求
    RHEL/CentOS 6.x使用EPEL6与remi的yum源安装MySQL 5.5.x
  • 原文地址:https://www.cnblogs.com/margiex/p/386849.html
Copyright © 2011-2022 走看看