delphi编译器如何生成ResourceString标识符? [英] How ResourceString Identifiers are generated by delphi compiler?

查看:108
本文介绍了delphi编译器如何生成ResourceString标识符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题就像Delphi编译器在编译应用程序时生成数字标识符并将其分配给所有ResourceStrings一样,很少有文档说明每次重新编译应用程序时都会重新生成Resourcestrings的数字标识符,并且他们警告依赖它,因为它再生后可能会改变。有很多第三方本地化工具使用和存储此资源字符串数字标识符以供内部参考和翻译。有什么方法可以阻止编译器重新生成此资源字符串数字标识符或强制其使用手动生成的数字标识符?

My question is like Delphi compiler generates and assign numerical Identifiers to all the ResourceStrings when application is compiled, There are few documents which says when ever application is recompiled the numerical Identifiers for Resourcestrings are regenerated, and they warn relying on it because it may change after regenerations. There ate so many third party localization tools that use and store this resourcestring numerical identifiers for internal reference and translation. Is there any way to stop compiler regenerating this resourcestring numerical identifiers or force it to use manually generated numerical identifiers?

推荐答案

通过指定--drc或 Project | Options | Delphi Compiler | Linker |输出资源字符串.drc文件开关,可以从编译器获得资源编译器可编译文件。这将指示编译器生成一个.drc文件,该文件将包含资源字符串内容编译器分配的值。

You can get a resource-compiler, compilable file from the compiler by specifying the --drc or "Project|Options|Delphi Compiler|Linker|Output resource string .drc file" switch. This will instruct the compiler to generate a .drc file that will contain the resource string contents and the compiler-assigned values.

对于每次构建,即使编译器重新分配了分配的值,您也将始终知道它们是什么。编译器会根据单元名称和资源字符串标识符为每个资源字符串生成一个标识符,因此即使 value 更改,该标识符也始终保持稳定。

If you do this for each build, even if the compiler rearranges the assigned values, you will always know what they are. The compiler generates an identifier for each resource string based on the unit-name and the resource string identifier, so that is always stable even if the value changes.

然后可以对该.drc文件进行翻译或其他处理,然后将其重新编译为.res文件。然后,可以将这个.res文件链接到一个特殊的仅资源 dll中,该dll具有指示该语言的 .dll以外的特定扩展名。正确设置系统语言后,将加载该dll,并使用字符串代替内置资源。

This .drc file can then be translated or otherwise processed and then recompiled into a .res file. This .res file can then be linked into a a special "resource-only" dll with a specific extension other than ".dll" that indicates the language. When the system language is properly set, this dll will then be loaded and the strings will be used instead of the built-in resource.

这篇关于delphi编译器如何生成ResourceString标识符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆