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.
- 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.
Create a projectAdd your
.csfiles or the project folder. Generated files are left out.Add the .resxUse the project's
.resx, or create one in Visual Studio (Project Properties > Resources) or in Extractor.Scan, then Skip or ExtractSkip the technical strings, extract the text with the template that matches the file.
Save the .resx in Visual StudioSaving it regenerates the strongly typed class with the new properties.
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.resxin the project's Properties folder, such as the defaultResources.resx.$(RESNAME).$(ID)
For a.resxyou 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.
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.
Other languages
- 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.