Visual C++

Visual C++ Localization

Localize a Visual C++ or MFC application from the compiled file, without the source code: Soluling reads the dialogs, menus, and string tables of your .exe or .dll, lets you translate them in a visual dialog editor, checks the translations, and builds localized executables or resource DLLs.

Visual C++ applications use standard Windows resources, and Soluling replaces only the resource part of the file; the compiled code stays exactly the same. This guide uses a small driving time calculator dialog as its example and takes it from English to Finnish, German, and Japanese.

Download Soluling

You build EXE Driving.exe Soluling 150 60 Driving Time Driving distance: Speed: Round time Calculate Fahrzeit Fahrstrecke: Geschwindigkeit: Ungefähre Uhrzeit Berechnen The dialog as it is in the EXE has been translated in the visual editor You ship EXE Driving.exe fi fi\Driving.exe de de\Driving.exe ja ja\Driving.exe A localized Driving.exe in each language folder, or MFC resource DLLs You build EXE Driving.exe Soluling 150 60 Driving Time Driving distance: Speed: Round time Calculate Fahrzeit Fahrstrecke: Geschwindigkeit: Ungefähre Uhrzeit Berechnen The dialog as it is in the EXE has been translated in the visual editor You ship EXE Driving.exe fi fi\Driving.exe de de\Driving.exe ja ja\Driving.exe A localized Driving.exe in each language folder, or MFC resource DLLs
Deploy a localized Driving.exe for each language (the default output), or the original Driving.exe with an MFC resource DLL for each language: DrivingFIN.dll, DrivingDEU.dll, and DrivingJPN.dll.
Input
Application or library file (.exe, .dll), or resource script (.rc)
Output
Localized files (fi\Driving.exe), resource DLLs (DrivingFIN.dll), a multilingual file, or localized .rc files
Runtime
Windows loads the resources of the file; MFC loads the resource DLL of the user's language
Preview
Visual dialog editor that shows the dialogs in each language and lets you move and resize controls

On this page

Tutorial

Localize a Visual C++ application, step by step

Six steps take the application from hard-coded English to localized files.

01

Prepare: make the application localizable

Dialogs, menus, and string tables are resources in your .rc file, so they are ready for localization as they are. Strings in the code are not. A typical problem looks like this:

CString result;
result.Format(L"Driving time is %d hours %d minutes", hours, minutes);

Internationalizing the application takes three changes:

  1. Move the strings from code to the string table. Add them to the STRINGTABLE of the .rc file with meaningful IDs, such as IDS_RESULT, and load them with LoadString or CString::LoadString.
  2. Use positional placeholders. Other languages may need the values in a different order. The positional printf functions of Visual C++, such as _swprintf_p, take %1$d and %2$d, so the translator can move them. Validation checks that the translation keeps every placeholder.
  3. Don't put the language in code. Fonts, sizes of dialogs, and images that contain text are resources too; keep them in the .rc file so that they can be localized.
Moving a hard-coded string to the string table The hard-coded format string stays English and fixes the order of the values. After internationalizing, the code loads the IDS_RESULT string resource, which has English and Finnish values with positional placeholders, and formats it. Before result.Format(L"Driving time is %d hours %d minutes", hours, minutes); ✕ Stays English, fixed word order Internationalize After wchar_t result[100]; CString format; format.LoadString(IDS_RESULT); _swprintf_p(result, _countof(result), format, hours, minutes); STRINGTABLE in Soluling IDS_RESULT English Driving time is %1$d hours %2$d minutes Finnish Ajoaika on %1$d tuntia %2$d minuuttia ✓ Translated with the dialogs, and the translator can reorder the values
02

Add: create a Soluling project

Build the application in Visual Studio, then drag and drop the .exe or .dll on Soluling. Project Wizard starts. This executable file method is the recommended one: you don't need the source code, and Soluling builds the localized files itself.

  • On the Resources page, select the resource types. Most applications need only Strings and Dialogs; add menus, versions, images, and the MFC Ribbon as needed.
  • If the application has been localized before, Soluling finds the existing localized files and imports their translations.
  • On the Select Languages page, add the target languages, and click Finish.

Do you build both 32-bit and 64-bit? Add one of them, and the other as a platform file, so each string is translated only once. Do you compress or encrypt your executables? Add the original file to Soluling, and compress the files that Soluling builds.

You can also add the .rc file instead. Soluling then writes localized .rc files, and you compile them into your application or into resource DLLs yourself.

Project Wizard Driving.exe goes through Project Wizard's Resources page (Strings and Dialogs selected), Existing translations page (DrivingFIN.dll found), and Select Languages page (Finnish, German, Japanese). Drop Driving.exe or Driving.rc Resources ☑ Strings ☑ Dialogs ☐ Menus, Ribbon, ... Existing translations DrivingFIN.dll ✓ Imported Languages Finnish (fi) German (de) Japanese (ja) The Existing translations page appears only when Soluling finds localized files.
03

Translate: in the grid and the visual dialog editor

The project tree shows the resources by type: dialogs, menus, string tables, and so on. Select a dialog, and the visual dialog editor shows it in the selected language, drawn with the real Windows controls. Selecting a row highlights its control. If a translation does not fit, move or resize the control with the mouse or the keyboard, for this language only.

  • Machine translation and translation memory. Click Use Machine Translation to translate with Amazon, Claude, DeepL, Google, Microsoft, ModernMT, or MyMemory, and reuse earlier translations from translation memory and terminology.
  • External translators. Send a translation package, an Excel file, or XLIFF to a translator, and import the results back. See teamwork.
  • Translators in a browser. Upload the project to Soluling Cloud and let translators work in Translate.
The translation grid and the visual dialog editor The grid lists the strings of dialog 101 with Finnish translations. The selected row, the distance label, is highlighted on the Finnish dialog in the visual editor. Grid: Dialog 101 Context English Finnish Text Driving Time Ajoaika 1000.Text &Driving distance: &Ajomatka: 1001.Text &Speed: &Nopeus: 1002.Text &Calculate &Laske 1003 (set in code) Visual dialog editor: Finnish Ajoaika FI ✕ Tiedosto Ohje Ajomatka: 220 Nopeus: 88 Laske Ajoaika on 2 tuntia 30 minuuttia
In the executable file, resources and controls are identified by their numeric IDs; the .rc file method shows the symbolic names, such as IDC_DISTANCE.
04

Check: find problems before release

Pseudo translation. Click Translate | Pseudo Translations | Fill, build, and run the application. Pseudo translations are longer and use accented characters, so texts that don't fit and strings still in the code (shown in plain English) stand out. See pseudo translation.

Pseudo-translated build

[Ðŕîvîñĝ Ţîɱé ___] PS ✕ [Ƒîļé __] [Ĥéļþ __] [Ðŕîvîñĝ ðîšţåñçé: ____________________] 220 [Šþééð: __________] 88 [Çåļçûļåţé ___] 2 hour(s) 30 minute(s) Too long and still English (hard-coded)

Validation. Soluling validates translations while you type and in batch (Validation | Validate Translations): missing translations, inconsistent placeholders and patterns, duplicate hotkeys, and more. See validation.

Validation: German

⚠ Inconsistent format string IDS_RESULT The original has %1$d and %2$d; the translation has only %1$d: Fahrzeit: %1$d Stunden ⚠ Duplicate hotkey &Fahrstrecke: / &Fahrzeit berechnen Both use Alt+F in the same dialog, so change one of them.
05

Build: create the localized files

Choose Home | Build All, and Home | Run Localized to start the application in a target language. On the Output sheet of the source, choose any combination of these outputs:

  • Localized files (the default): a copy of the application for each language. The code is identical to the original; only the resources are translated.
  • Resource DLLs: a resource-only DLL for each language, named the way MFC looks for them, such as DrivingFIN.dll. One installation holds every language.
  • Multilingual file: one application that contains every language. Windows uses the one that matches the user interface language.
  • Embedded file: the resource DLLs inside the application as a custom resource. You write the code that extracts them.
The kinds of output Localized files: a complete Driving.exe in the fi, de, and ja folders. Resource DLLs: DrivingFIN.dll, DrivingDEU.dll, and DrivingJPN.dll next to the original Driving.exe. Multilingual file: one Driving.exe with every language. Embedded file: one Driving.exe with the resource DLLs inside. Localized files (default) DIR x64\Release\ EXE Driving.exe original, English fi fi\Driving.exe de de\Driving.exe ja ja\Driving.exe Resource DLLs DIR x64\Release\ EXE Driving.exe original, unchanged DLL DrivingFIN.dll DLL DrivingDEU.dll DLL DrivingJPN.dll Multilingual file DIR x64\Release\all\ EXE Driving.exe every language; Windows chooses by the UI language Embedded file DIR x64\Release\ EXE Driving.exe resource DLLs inside; your code extracts them
06

Update: translate only what changed

When the application changes, build it in Visual Studio and click Home | Scan. Soluling compares the new resources with the project, keeps the existing translations, adds the new strings, and marks the rows whose original text changed so that their translations are checked again. Rows are matched by the resource and control IDs, so keep them stable. Translate the new rows and build again.

You can automate the scan and build steps in your build pipeline with the SoluMake command-line tool.

Reference

Code and resources are separate parts of the executable

Visual Studio compiles the .rc file into a .res file and links it into the portable executable (PE) file. The .exe or .dll has two parts: the compiled code and the resources. Soluling copies the file and replaces only the resources with the translated ones, so a localized file runs exactly the same code. A resource DLL contains only the translated resources, no code; the application loads its resources from the DLL instead of from itself.

MFC adds its own resource types, such as the ribbon (RT_RIBBON_XML). Check Ribbon on the Resources page to translate it. With the .rc file method, add the ribbon file (res\ribbon.mfcribbon-ms) to the project too.

Initial language of an MFC application

MFC loads a resource DLL automatically when the application starts. It looks for the application name followed by a three-letter language code, such as DrivingFIN.dll, trying these languages in order and stopping at the first DLL it finds. If there is none, the application uses its own resources.

How an MFC application chooses its resource DLL First the user's UI language, then the user's UI language without the sublanguage, then the system's UI language with and without the sublanguage, then the LOC language, and finally the application's own resources. User UI GetUserDefault- UILanguage DrivingFIN.dll ✓ Loaded User neutral Without the sublanguage System UI GetSystemDefault- UILanguage ± sublanguage LOC DrivingLOC.dll Original Driving.exe own resources Non-MFC applications load a resource DLL themselves with LoadLibraryEx.

Change the language at runtime

MFC chooses the resource DLL when the application starts. To change the language while the application runs, load another resource DLL, make MFC use it, and create the windows again:

// Use the Finnish resources from now on
HINSTANCE resources = ::LoadLibraryEx(L"DrivingFIN.dll", nullptr,
  LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE);

if (resources != nullptr)
{
  AfxSetResourceHandle(resources);
  // Recreate the open windows and menus so that they load the new resources
}

Soluling has a ready-made runtime language switch for Delphi and .NET applications; see the Delphi VCL and Windows Forms guides.

Translate in Soluling Cloud

With Soluling Cloud, translators use Translate in a browser. How you start depends on what you localize:

  • Resource scripts (.rc). Upload the .rc file on the dashboard, translate, and download the localized .rc files. You compile them into your application or into resource DLLs.
  • Executables (.exe, .dll). Soluling Cloud can't scan these itself. Create the project in Soluling Desktop, and choose Translate | Configure Cloud to upload it. Use Import from Cloud to get the translations back and build the localized files locally. Your application files never leave your machine.

To run the scan, upload, import, and build steps in your build pipeline, use SoluMake. See the Cloud tutorial and workflows.

Do and don't

Do

  • Put every string the user sees into the resource such as dialog or string table.
  • Use positional placeholders (%1$d) so that translators can easily reorder the values.
  • Leave room in dialogs for longer text, or resize the controls per language in the dialog editor.
  • Keep resource and control IDs stable after translation starts.
  • Add the 64-bit and 32-bit files as one source with platform files.
  • Pseudo-translate before the first real translation.

Don't

  • Hard-code strings in the code, including format strings.
  • Build sentences from pieces.
  • Add a compressed or encrypted executable to Soluling; compress the output instead.
  • Rename the resource DLLs; MFC looks for DrivingFIN.dll by its exact name.
  • Draw text into images; keep it in the string table.

Typical localizability problems

See also internationalization and pseudo translation.

Problem How it shows Find and fix
Strings in code English text Move the strings to the string table.
Fixed word order Translations that can't place the values correctly Use positional placeholders, such as %1$d, with _swprintf_p.
Sentences built from pieces Word order and grammar are wrong in the translation Use one string with placeholders.
Dialogs only fit English Clipped text in the pseudo or localized build Make the controls wider, or resize them per language in the dialog editor.
Hotkeys collide Alt+letter selects the wrong control Validation finds duplicate hotkeys.

Troubleshooting

Symptom Likely cause What to do
Soluling can't read the file The executable is compressed or encrypted Add the original executable, and compress or encrypt the files that Soluling builds.
The application stays in English with resource DLLs The DLL name doesn't match what MFC looks for, or it isn't next to the application Check the name (DrivingFIN.dll) and folder; a non-MFC application must load the DLL itself.
The ribbon is not translated The Ribbon resource type is not selected Check Ribbon on the Resources sheet of the source, and scan.
Strings appear twice Both the 32-bit and the 64-bit file were added as sources Keep one as the source and add the other as a platform file.
Text set in code is in English The code uses hard-coded strings Move them to the string table.

Samples

The Visual C++ samples are in Samples\VisualCpp of the Soluling installation and on GitHub:

  • MFC: an MFC application with localized resource scripts and a Soluling project for the executable.
  • Ribbon: an MFC application with a ribbon.

See Visual C++ localization in the Desktop documentation for all the details.

FAQ

No. Soluling reads the resources of the compiled .exe or .dll and builds the localized files from it. You need the source code only to fix internationalization problems, such as hard-coded strings.

The executable: Soluling builds the localized files itself, and you don't need to compile anything. Localize the .rc file if you want the localized resource scripts in source control.

Use localized files if you install one language for each user. Use resource DLLs if one installation should hold every language; MFC loads the right one automatically.

Not automatically. Load another resource DLL, call AfxSetResourceHandle, and create the windows again. See Change the language at runtime.

Yes. Soluling localizes the standard Windows resources of any PE file. Only the automatic loading of resource DLLs is an MFC feature.

Related

All guides