views:

798

answers:

6

Ulimately I just wanted to extract strings from the .rc file so I could translate them, but anything that goes with .rc files works for me.

A: 

Maybe this helps? (http://social.msdn.microsoft.com/forums/en-US/regexp/thread/5e87fce9-ec73-42eb-b2eb-c821e95e0d31/)

They are using the following regex to find the stringtable in the rc source:

(?<=\bSTRINGTABLE\s+BEGIN\s+).*?(?=\s+END\b)

Edit - And you can read the key values pairs with the following statement with the MultiLine option:

@"\s+(.*?)\s+""(.*)""";

Thomas
A: 

That will definitely help. But getting the strings from string tables is the easy part. I would like to be also able to extract e.g. captions from dialog boxes or menu items.

djeidot
A: 

This sounds like a job for a SED script.

By running this command line: sed.exe -n -f sed.txt test.rc

The following SED script will extract all the quoted strings from the input test.rc file:

# Run Script Using This Command Line
#
#   sed.exe -n -f sed.txt test.rc
#

# Check for lines that contain strings
/\".*\"/ {
    # print the string part of the line only
    s/\(.*\)\(\".*\"\)\(.*\)/\2/ p
}
jussij
+1  A: 

For a real-world project, you'll want to not only extract them but also put them back in. And keep track of updates. This is going to be unmanageable for anything but the most trivial applications. Take a look at specialized software like appTranslator (www.apptranslator.com). Not free but some regex parsing isn't going to cut it - I know, I've tried plenty.

Roel
+1  A: 

Although rc files seems an obvious starting point for translation, it's not. The job of developers is to make sure the app is translatable. It's not to manage translations. Starting translations from the exe, although somewhat counter-intuitive, is a way better idea. Read more about it here: http://www.apptranslator.com/misconceptions.html

Serge - appTranslator
A: 

ResxCrunch will be out sometimes soon. It will edit multiple resource files in multiple languages in one single table.

Germstorm