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.
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.rcfiles - 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
- How Visual C++ localization works
- Initial language of an MFC application
- Change the language at runtime
- Translate in Soluling Cloud
- Do and don't
- Typical localizability problems
- Troubleshooting
- Samples
- FAQ
Localize a Visual C++ application, step by step
Six steps take the application from hard-coded English to localized files.
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:
-
Move the strings from code to the string table. Add them to the
STRINGTABLEof the.rcfile with meaningful IDs, such asIDS_RESULT, and load them withLoadStringorCString::LoadString. -
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$dand%2$d, so the translator can move them. Validation checks that the translation keeps every placeholder. -
Don't put the language in code. Fonts, sizes of dialogs, and images that contain text are resources too; keep them in the
.rcfile so that they can be localized.
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.
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.
.rc file method shows the symbolic names, such as IDC_DISTANCE.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
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
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.
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.
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.
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.rcfile on the dashboard, translate, and download the localized.rcfiles. 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.dllby 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
.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..rc file if you want the localized resource scripts in source control.AfxSetResourceHandle, and create the windows again. See Change the language at runtime.Related
- Visual C++ localization - the full Desktop documentation
- Output files - localized files, resource DLLs, multilingual and embedded files
- Runtime language change - in other platforms
- Supported formats - everything else Soluling localizes