#define/#include support during resource replacement

Anton

2006-09-13 19:35:29

Suppose I have following strings in my application (extracted with help of Restorator):

Code: Select all

STRINGTABLE
{
1, "Monday"
2, "Tuesday"
3, "Wednesday"
}
I want to automatically translate them into German via command line. So I create following file:

Code: Select all

STRINGTABLE
{
1, "Montag"
2, "Dienstag"
3, "Mittwoch"
}
Everything works fine... while resource identifiers stay the same during every build. But in some cases these identifiers may be changed, and the English version continues to run smoothly (symbolic identifiers are used both in application code and in original resource file), though German version would show invalid day names.

To solve this problem I propose to introduce symbolic identifiers of resources, which shall be initialized in C-style header file.
Such functionality allows us to rewrite the example as follows:

resource.rh (this file is used to compile the application as well)

Code: Select all

#define IDS_MONDAY 1
#define IDS_TUESDAY 2
#define IDS_WEDNESDAY 3
week.rc

Code: Select all

#include "resource.rh"
STRINGTABLE
{
IDS_MONDAY, "Montag"
IDS_TUESDAY, "Dienstag"
IDS_WEDNESDAY, "Mittwoch"
}
Looks good, right? :)

Same approach may be used for other types of resources (icons, bitmaps, etc.) to get rid of hard-coded constants.

PS: I know I might have used symbolic names for resources, but... :)

florian

2006-09-20 05:49:28

Restorator already supports #define statements, so this should really work already, does it not?

Of course, it does not create .rc files with those symbolic constants, because even with the header file it would not know which numbers to replace with which symbolic constant.

I am, however, working on an extension for Restorator that automatically translates the resources based on a dictionary. The dictionary can be populated automatically by comparing the original and translated software. Then, when translating a new version (or a completely different software), the extension prompts to translate only the strings that aren't yet in the dictionary.

Would that solve your needs?

Florian