编译资源文件
您现在可以编译前一节中创建的自定义语言子目录中的资源文件了。
如果您需要编译包含非拉丁语脚本的自定义资源文件,例如西里尔语、中文、朝鲜语、日语、希伯来语和阿拉伯语,则编译之前,需要为这些语言配置环境区域设置。这样可以确保使用恰当的语言脚本。有关更多信息,请参见“参考:配置环境区域设置”。
- 打开 ro 语言子目录。
此教程将使用以下三个文件:
-
CRWebFormViewer.txt
-
SCRShared.txt
-
Viewer.txt
前两个文件包含可用于基于 Web 的 CrystalReportViewer 控件的资源字符串。最后一个文件包含可用于基于 Windows 的 CrystalReportViewer 控件的资源字符串。
- 打开 Viewer.txt 以查看其内容。
<table>
<colgroup>
<col style="width: 100%" />
</colgroup>
<thead>
<tr class="header">
<th><img src="images/8yfdxzdx.alert_note(zh-cn,VS.90).gif" alt="Note" class="note" />注意</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><p>此罗马尼亚语文件夹目前包含西班牙语字符串。有关更多信息,请参见本教程中前面介绍的步骤:<a href="ms227600(v=vs.90).md">“设置自定义资源文件目录”</a>。</p></td>
</tr>
</tbody>
</table>
CrystalReportViewer 控件的本地化后的字符串会以当前语言显示。
关闭 Viewer.txt。
从“开始”菜单,转到“程序”>“Visual Studio”>“Visual Studio 工具”>“Visual Studio 命令提示符”。
将目录更改为资源文件目录:
cd c:\CrystalReportViewer_resource_files\ro\
按照下面显示的语法运行 resgen 实用程序以编译 .txt 文件。
<table>
<colgroup>
<col style="width: 100%" />
</colgroup>
<thead>
<tr class="header">
<th><img src="images/8yfdxzdx.alert_note(zh-cn,VS.90).gif" alt="Note" class="note" />注意</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><p>逗号前面或后面不要输入空格。</p></td>
</tr>
</tbody>
</table>
resgen /compile CRWebFormViewer.txt,CrystalDecisions.Web.resources
resgen /compile SCRShared.txt,CrystalDecisions.Shared.resources
resgen /compile Viewer.txt,CrystalDecisions.Windows.Forms.resources
- 运行 al.exe 实用程序,为每个资源文件创建一个 DLL。
<table>
<colgroup>
<col style="width: 100%" />
</colgroup>
<thead>
<tr class="header">
<th><img src="images/8yfdxzdx.alert_note(zh-cn,VS.90).gif" alt="Note" class="note" />注意</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><p>输出名称将扩展名 resources.dll 改为 custom_resources.dll。</p></td>
</tr>
</tbody>
</table>
al.exe /t:lib /embed:CrystalDecisions.Web.resources /culture:ro /out:CrystalDecisions.Web.custom_resources.dll
al.exe /t:lib /embed:CrystalDecisions.Shared.resources /culture:ro /out:CrystalDecisions.Shared.custom_resources.dll
al.exe /t:lib /embed:CrystalDecisions.Windows.Forms.resources /culture:ro /out:CrystalDecisions.Windows.Forms.custom_resources.dll
- 键入 dir 查看已编译的 DLL。
您已经为此子目录完成了资源编译。
- 如果还有其他想要编译的自定义语言,请对每种语言重复本节中操作。
<table>
<colgroup>
<col style="width: 100%" />
</colgroup>
<thead>
<tr class="header">
<th><img src="images/8yfdxzdx.alert_note(zh-cn,VS.90).gif" alt="Note" class="note" />提示</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><p>为了节省时间,可以将所有六个命令输入一个批处理文件中。请记住,要访问正确的环境变量,必须从 Visual Studio 命令提示下运行该批处理文件。</p></td>
</tr>
</tbody>
</table>
- 编译完自定义资源后,关闭“Visual Studio 命令提示符”。
在下一节中,将配置网站或 Windows 项目,以便从全局位置或自定义位置访问自定义资源。
如果要构建一个网站,请继续浏览“配置全局或本地自定义资源”。
如果要生成 Windows 项目,请继续浏览 “配置对 Windows 应用程序的多语言客户端支持”部分。