This forum is read-only. Please post new topics in our Q&A forum.

#define/#include support during resource replacement

General discussion about using Restorator.

Moderator: florian

Locked
Anton
New User
Posts: 4
Joined: Wed Sep 13, 2006 5:49 pm
Location: Kiev, Ukraine

#define/#include support during resource replacement

Post by Anton » Wed Sep 13, 2006 6:35 pm

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... :)

User avatar
florian
Bome Software: Founder
Posts: 2435
Joined: Thu Apr 28, 2005 10:09 pm
Location: Munich, Germany
Contact:

Post by florian » Wed Sep 20, 2006 4:49 am

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

Locked