Lingobit Extractor · Delphi
Extract hard-coded strings from Delphi code into resourcestring.
A message written as 'Order saved' in Pascal code stays in English in every language. Lingobit Extractor moves it into the resourcestring section of a unit and puts its name in place of the text, so the compiler stores it in the EXE's resources and it can be translated.
- Files
- .pas, .dpr, .p
- Resources
- A resourcestring unit
- In the code
- The unit and the string name
- Trial
- 30 days, a separate download
What Extractor changes in your Delphi code.
One string, before and after. The name is made from the words of the text: each word begins with a capital letter, without a separator, and ends in Str.
Before: OrderForm.pas
procedure TOrderForm.SaveClick(Sender: TObject);
begin
SaveOrder;
StatusBar.SimpleText := 'Order saved';
end;
After: OrderForm.pas
procedure TOrderForm.SaveClick(Sender: TObject);
begin
SaveOrder;
StatusBar.SimpleText := AppStrings.OrderSavedStr;
end;
New in the resources: AppStrings.pas
unit AppStrings;
interface
resourcestring
OrderSavedStr = 'Order saved';
implementation
end.
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
.pasand.dprfiles or the whole folder.Add a resource unitExtractor creates the unit with the
resourcestringsection, or uses one it created before.Scan, then Skip or ExtractSkip the technical strings, such as SQL and registry keys; extract the text.
Use the unitAdd the resource unit to the project and to the
usesclause of the changed units.BuildBuild as usual. The strings are now in the resources of your EXE.
The code that loads the string.
Each extracted string gets a replace template. Pick one per resource file or per string.
$(RESNAME).$(ID)
The unit name and the string name, such asAppStrings.OrderSavedStr.
The resourcestring keyword tells the Delphi compiler to store the strings in the resources of the EXE, next to the forms.
Then translate the build.
Lingobit Localizer reads the resource strings from your EXE, together with the forms, and writes a resource module such as MyApp.DEU 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.
Delphi string extraction FAQ
Why resourcestring and not constants?
A const string is compiled into the code. A resourcestring goes into the resources of the EXE, where the Delphi runtime loads it from the resource module of the user's language.
Does Extractor touch my forms?
No. Text on forms is already in the DFM resources, and Lingobit Localizer translates it there. Extractor works with the strings in your Pascal code.
Does it work with C++Builder?
Yes. C++Builder code is C++: Extractor moves its strings into an .rc2 string table, as on the C and C++ page.
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 Delphi 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.
- C#Hard-coded strings in C# code into .resx resources.
- Visual Basic .NETHard-coded strings in Visual Basic .NET code into .resx resources.
- JavaHard-coded strings in Java code into .properties files.