Lingobit Extractor · C and C++

Extract hard-coded strings from C and C++ code into resources.

Text written in _T("…") or L"…" never reaches a translator. Lingobit Extractor moves it into a string table in a separate .rc2 file and puts _LS( IDS_… ) in its place, so the text is in the build's resources and can be translated.

View pricing

C++OrderDlg.cppExtractvoid COrderDlg::OnSave(){ SaveOrder(); SetStatus(_T("Order saved"));_LS( IDS_ORDER_SAVED ));}RCStrings.rc2STRINGTABLEBEGIN IDS_ORDER_SAVED "Order saved"END"Order saved"IDS_ORDER_SAVED C++OrderDlg.cppExtractvoid COrderDlg::OnSave(){ SaveOrder(); SetStatus( _T("Order saved"));_LS( IDS_ORDER_SAVED ));}RCStrings.rc2STRINGTABLEBEGIN IDS_ORDER_SAVED "Order saved"END"Order saved"IDS_ORDER_SAVED
Files
.c, .cpp, .h, .hpp
Resources
String table in a separate .rc2
In the code
_LS, _LSW, or _LSA with the ID
Trial
30 days, a separate download

What Extractor changes in your C++ code.

One string, before and after. The ID is made from the words of the text: IDS_ and the words in upper case, joined with _. Numbers come from the range you set for the file, 15000–25000 by default.

Before: OrderDlg.cpp

void COrderDlg::OnSave()
{
    SaveOrder();
    SetStatus(_T("Order saved"));
}

After: OrderDlg.cpp

void COrderDlg::OnSave()
{
    SaveOrder();
    SetStatus(_LS( IDS_ORDER_SAVED ));
}

New in the resources: Strings.rc2 and Strings.h

// Strings.rc2
STRINGTABLE
BEGIN
    IDS_ORDER_SAVED  "Order saved"
END

// Strings.h
#define IDS_ORDER_SAVED  15000

From hard-coded text to resources in five steps.

Not every string is text: a class name, an SQL query, or a registry key stays in the code. You decide what moves, and Extractor remembers it.

Lingobit ExtractorScanScanStringSourceState"Order saved"OrderDlg.cpp:42NewExtract"%d"OrderDlg.cpp:57Newfiltered out: no letters"OrderWindow"OrderDlg.cpp:12NewSkip"SELECT * FROM Orders"OrderDb.cpp:30NewSkip"Print the order"OrderDlg.cpp:88NewExtract"Software\\MyApp"Settings.cpp:9NewSkip"Gift wrap"OrderDlg.cpp:95NewAt the next Scan, skipped strings stay skipped and extracted ones stay in the resources:only the new string is New. Lingobit ExtractorScanScanStringState"Order saved"NewExtract"%d"Newfiltered out: no letters"OrderWindow"NewSkip"SELECT * FROM Ord…"NewSkip"Print the order"NewExtract"Software\\MyApp"NewSkip"Gift wrap"NewAt the next Scan only the new stringis New; skipped ones stay skipped.
  1. Create a projectFile > New Project, then add your source files or the whole folder. Set which files to parse: most teams leave out stdafx.h and stdafx.cpp.

  2. Add a resource fileProject > Add Resource creates the .rc2 for the extracted strings, with the ID range, the header file, and the template.

  3. Scan, then Skip or ExtractExtractor highlights every string literal in the preview. Skip the technical ones, extract the text.

  4. Include the new filesAdd the .rc2 to your main .rc (Resource View > Resource Includes in Visual Studio), and include ResString.h and the header, usually in the precompiled header.

  5. BuildBuild as usual. The strings are now in the string table of your EXE or DLL.

The code that loads the string.

Each extracted string gets a replace template. Pick one per resource file or per string.

  • _LS( $(ID) )
    Loads the string as TCHAR const *. The default.
  • _LSW( $(ID) )
    Loads it as wchar_t const *.
  • _LSA( $(ID) )
    Loads it as char const *.

The three macros are defined in ResString.h. Each string is loaded from the resources once, at the first call. You can also write your own template with $(ID), $(NUM_ID), $(SRC_STR), and $(SRC_TEXT).

Then translate the build.

Lingobit Localizer reads the string table from your EXE or DLL, together with the dialogs and menus, and writes a resource-only DLL for each language, or a localized EXE.

Before translation, check the result with Pseudo Translate in Lingobit Localizer: if a text still stays in English, it is still in the code. Pseudo Translate: Professional and higher.

Pseudo TranslateRun Localized ApplicationNew OrderNew ÖrderNeCustomer:Cüßtömer:CüQuantity:Qüäntity:QüShip todayShip tödäyShiPrint receiptPrint receiptPriCreateCreäteCCancelCäncelCOrder savedÖrder ßävedÖrdFrom the resourcesWorks as the original Pseudo TranslateRun Localized ApplicationNew OrderNew ÖrderNeCustomer:Cüßtömer:CüQuantity:Qüäntity:QüShip todayShip tödäyShiPrint receiptPrint receiptPriCreateCreäteCCancelCäncelCOrder savedÖrder ßävedÖrdFrom the resourcesWorks

C++ string extraction FAQ

Does Extractor change my main .rc file?

No. The strings go into a separate .rc2 that Extractor creates and fills; you include it in the main .rc once. Extractor works only with resource files it created.

What is _LS?

A macro from ResString.h that loads a string from the resources by its ID and returns TCHAR const *. _LSW returns wchar_t const *, _LSA returns char const *. Each string is loaded once.

Can I use my own loading function?

Yes. Set your own replace template for the resource file, for example with $(ID) for the identifier or $(NUM_ID) for its number.

What happens to strings I skip?

They stay in the code and keep the Skip state. At the next Scan only new strings show up.

Try Extractor on your own C++ code.

The trial runs for 30 days with every function. In each resource file the first 50 extracted strings are written as they are; after that, some may end in _TRIAL.

  • Lingobit ExtractorAll languages, how to work with Extractor, and the check after extraction.
  • C#Hard-coded strings in C# code into .resx resources.
  • Visual Basic .NETHard-coded strings in Visual Basic .NET code into .resx resources.
  • DelphiHard-coded strings in Delphi code into a resourcestring unit.
  • JavaHard-coded strings in Java code into .properties files.