How ResourceString Identifiers are generated by delphi compiler?

753 views Asked by At

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?

2

There are 2 answers

4
Allen Bauer On BEST ANSWER

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.

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.

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.

0
David Heffernan On

You don't have any control over how the compiler generates the string table resource, and the numeric identifier.

If you wish to use external tools that rely on the numeric identifier then you should probably build the string table in the classic way. Define the string table in a text file. Compile to a resource and link into a language specific resource DLL. This will make the coding less convenient, and it's for you to decide whether or not that trade off is worth being able to use your external tools.