Lingobit Extractor · C#

Extract hard-coded strings from C# code into .resx resources.

A message written as "Order saved" in C# stays in English in every language. Lingobit Extractor moves it into a .resx file and puts the strongly typed resource property in its place, so it is compiled into the assembly's resources and can be translated.

View pricing

C#OrderForm.csExtractvoid OnSave(){ SaveOrder(); statusLabel.Text = "Order saved";Properties.UI.str_Order_saved;}RESXUI.resxName Valuestr_Order_saved Order savedOrder savedstr_Order_saved C#OrderForm.csExtractvoid OnSave(){ SaveOrder(); statusLabel.Text = "Order saved";Properties.UI.str_Order_saved;}RESXUI.resxName Valuestr_Order_saved Order savedOrder savedstr_Order_saved
Files
.cs; *.Designer.cs, *.g.cs, and AssemblyInfo are left alone
Resources
.resx
In the code
The strongly typed resource property
Trial
30 days, a separate download

What Extractor changes in your C# code.

One string, before and after. The name is made from the words of the text: str_ and the words joined with _.

Before: OrderForm.cs

void OnSave()
{
    SaveOrder();
    statusLabel.Text = "Order saved";
}

After: OrderForm.cs

void OnSave()
{
    SaveOrder();
    statusLabel.Text = Properties.UI.str_Order_saved;
}

New in the resources: Properties\UI.resx

Name               Value
str_Order_saved    Order saved

Extractor also reads XAML, with bindings to a resource wrapper class, and ASP.NET pages, with resource expressions.

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 projectAdd your .cs files or the project folder. Generated files are left out.

  2. Add the .resxUse the project's .resx, or create one in Visual Studio (Project Properties > Resources) or in Extractor.

  3. Scan, then Skip or ExtractSkip the technical strings, extract the text with the template that matches the file.

  4. Save the .resx in Visual StudioSaving it regenerates the strongly typed class with the new properties.

  5. BuildBuild as usual. The strings are now in the assembly's resources.

The code that loads the string.

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

  • Properties.$(RESNAME).$(ID)
    For a .resx in the project's Properties folder, such as the default Resources.resx.
  • $(RESNAME).$(ID)
    For a .resx you added elsewhere in the project.

Visual Studio generates the strongly typed class. After extraction, open the .resx in Visual Studio and save it once, and the new properties appear.

Then translate the build.

Lingobit Localizer reads the resources from your compiled assembly, together with the forms and windows, and writes a satellite assembly for each language. .NET Framework 4.8 and .NET 5–10.

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

Why do the new properties not compile right after extraction?

Visual Studio generates the strongly typed class. Open the .resx in Visual Studio and save it once, and the properties appear.

Which template do I choose?

Properties.$(RESNAME).$(ID) for a .resx in the Properties folder, such as the default Resources.resx; $(RESNAME).$(ID) for one you added elsewhere.

Does Extractor touch Designer files?

No. *.Designer.cs, *.g.cs, *.g.i.cs, and AssemblyInfo are left out. Form text is already in the form's resources, and Lingobit Localizer translates it there.

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 and C++Hard-coded strings in C and C++ code into an .rc string table.
  • 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.