Win32 resource scripts

Translate .rc files, or translate what they compile into.

Lingobit Localizer can translate a resource script as text: the quoted strings in .rc and .rc2 files, with everything else left as written. For an application you ship, translating the compiled EXE or DLL usually goes further: you see each dialog, fix its layout, and need no rebuild per language.

Your source RC MyApp.rc Lingobit Localizer Project SourceGerman New Order Neue Bestellung Customer: Kunde: Quantity: Menge: Each string, translated in the project You get MyApp.rc de\MyApp.rc fr\MyApp.rc ja\MyApp.rc A translated file for each language; you compile them Your source RC MyApp.rc Translate in Lingobit Project SourceGerman New Order Neue Bestellung Customer: Kunde: Quantity: Menge: You get MyApp.rc source de\MyApp.rc fr\MyApp.rc ja\MyApp.rc
Translated
The text in double quotes
Skipped
#include, #define, comments
Encodings
ANSI, UTF-8, UTF-16, as in the original
Output
de\MyApp.rc for each language
On this page

The .rc file or the compiled build?

Both start from the same resources. The difference is what Lingobit can see: text in a script, or the dialogs as Windows draws them.

Translating the .rc file compared with translating the compiled EXE or DLL
The .rc as textThe EXE or DLL
What is translatedEvery quoted stringDialogs, menus, string tables, version info, by resource
Dialog preview and layoutNoVisual editor: move and resize controls; truncated text is reported
Identified byPlace in the fileResource type and ID
ResultA translated .rc you compile for each languageA localized EXE or DLL, or resource-only DLLs, without a rebuild
EditionProfessional and higherEvery edition

The text route fits when the translated .rc itself must go into your repository or into someone else's build. For everything else, start from the build: Win32 / MFC guide.

How the .rc file is translated as text.

Add MyApp.rc or MyApp.rc2 to a project; it opens as C++ source. Each string in double quotes becomes one row in the project table. Create Localized Files writes de\MyApp.rc with the translations in the same places and every other character as it was.

STRINGTABLE
BEGIN
    IDS_SAVED   "Datei gespeichert."          // was "File saved."
    IDS_ERROR   "%s kann nicht geöffnet werden."
END

IDD_ABOUT DIALOGEX 0, 0, 200, 80
CAPTION "Info über MyApp"
FONT 9, "Segoe UI"                            // lock: a font name
BEGIN
    LTEXT "MyApp Version 1.0", IDC_STATIC, 10, 10, 180, 10
    DEFPUSHBUTTON "OK", IDOK, 140, 60, 50, 14
END

What stays your job

  • Lock what is not text. Font names, window class names in CONTROL statements, and file names are quoted strings too. Locked strings are not translated and not sent to translators.
  • Language and code page. The LANGUAGE statement and #pragma code_page are not changed; set them in the translated file, or save it as UTF-16.
  • Layout. Coordinates stay as in the original. A German label that is a third longer needs a wider control, which the text route cannot show you.
  • The build. Compile each language's .rc into its EXE or resource-only DLL, for every release.

In the next release, Scan for Changes compares the new .rc with the project. Because strings are found by their place in the file, a moved or edited string can come back as new; translation memory then suggests its old translation.

Recommended

Translate the compiled build instead.

Add MyApp.exe or the DLLs to the project. Lingobit reads the dialogs, menus, and string tables the resource compiler put there, by resource type and ID, and shows each dialog in the visual editor.

  • See the dialog: type the translation in place, then move and resize controls; the changes are stored with the translation.
  • Check the layout: Validation reports text cut off in dialogs, controls outside the dialog, and duplicate hotkeys.
  • No rebuild: Create Localized Files writes a localized EXE or DLL, or resource-only DLLs such as MyAppDEU.dll.
  • Existing translations: localized EXE files or language DLLs you already have can be imported, also ones built from translated .rc files.

Questions.

Can I keep using my .rc files and still translate the build?

Yes. Developers keep editing the English .rc as before; Lingobit works on what the build produces and brings only new and changed resources to translation in each release.

What about strings that are still in the C++ code?

Text hard-coded in .cpp files is not in the resources at all. Lingobit Extractor moves it into the string table first. See Lingobit Extractor.

Are .res files read?

The compiled EXE or DLL is the input for the binary route. Translate the file the .res is linked into.

Does this work for MFC Ribbon files?

Yes. .mfcribbon-ms files are read as their own format, with the category, panel, and button text (Professional and higher).