3

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?

Cœur
  • 32,421
  • 21
  • 173
  • 232
user4916191
  • 125
  • 9

2 Answers2

2

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.

David Heffernan
  • 572,264
  • 40
  • 974
  • 1,389
2

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.

Allen Bauer
  • 16,167
  • 2
  • 51
  • 73
  • How will this work with a project in maintenance? You add new strings. You go back to your external tool. You load up your latest translations for a specific language, but the numbers have changes. And now it's confused. – David Heffernan May 22 '15 at 19:00
  • Have you seen the content of the .drc file? Look at that first and you may then understand how it works. – Allen Bauer May 22 '15 at 19:55
  • I understand that. I just wonder how external tools can work with shifting sands. – David Heffernan May 22 '15 at 19:58
  • Because they work with the identifiers, not the raw numbers. How would other tools work with a normal, manually constructed .rc file with resource strings? Usually, they expect to use a fixed identifier and leave the actual values alone. – Allen Bauer May 22 '15 at 21:54