How are ResourceStrings generated by the delphi compiler?

My question is similar to the Delphi compiler that generates and assigns numeric IDs to all resource strings when compiling an application. There are several docs that say that when ever an application is recompiled, the numeric IDs for the Resourcestrings are regenerated and they warn, relying on it because this might change after the regeneration. There have been so many third party localization tools out there that use and store these numeric resource IDs for internal reference and translation. Is there a way to stop the compiler from regenerating these numeric resource IDs, or to force it to use hand-generated numeric IDs?

+3


source to share


2 answers


You can get the resource compiler compiled file from the compiler by specifying the -drc option or "Project | Options | Delphi Compiler | Linker | Output resource string.drc file". This will instruct the compiler to generate a .drc file that contains the content of the resource string and the compiler-assigned values.

If you do this for each assembly, even if the compiler reorders the assigned values, you will always know what it is. The compiler generates an ID for each resource line based on the unit name and the resource line ID, so it 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 in a special DLL resource with a specific extension other than ".dll" that specifies the language. When the system language is correctly installed, this DLL will be loaded and strings will be used instead of the embedded resource.

+2


source


You have no control over how the compiler generates the string table resource and numeric ID.



If you want to use external tools that rely on a numeric identifier, you should probably build your string table in the classic way. Define a table of strings in a text file. Compile the resource and link it to the language DLL of the resource. This will make coding less convenient and you will need to decide if the trade-off is worth using your external tools.

+2


source







All Articles