Resourcing hard coded strings in Delphi

Software localization tools like our Sisulizer localizes binaries, like executables (.exe) or library files (.dll). That has many advantages like

  • You do not need to give third-parties like translators access to your source code
  • Your source code will not be changed itself
  • Less files need to be exchanged with your translators

to name a few.
This works fine when your strings are stored in string tables of Windows resources. Luckily this is very easy in Delphi. Just use a resourcestring block instead of hard-coding the string.

Don’t use hard coded strings like

procedure TForm1.FormCreate(Sender: TObject);

begin

  Label2.Caption := 'Click the above button to process data'; 

end;

Use Delphi resourcestring blocks like

procedure TForm1.FormCreate(Sender: TObject);

resourcestring

  SClickButton = 'Click the above button to process data';

begin

  Label2.Caption := SClickButton;

end;

Use unique and descriptive names as resource strings. That gives you and your translator a much better idea of the context of the string, and a way better chance for a fast and good translation.

What if you have hard coded strings in 100k+ lines of Delphi code

What do you want to hear? Bad luck, internationalization tools are very expensive, chances a good that you have a lot of stupid work in front of you? I fear I have given too much people answers more of less like these. Shame on me.
First, you are not alone. And even better there is a great tool around that will help you through that job. And all this at a very competitive price.

Resourcing with CodeExplorer

CodeExplorer provides a whole set of ways to convert your hard coded strings to resources.

  • Converting a hard coded string at the cursor.
  • Converting all hard coded strings of an entire file, or even multiple files with sophisticated wizards
  • Converting hard coded strings by using the command line tool

And it comes with various options for scanning, and converting, I.e. it helps you to identify strings that do not need to be localized at all, or do need special attention like SQL statements. It also provides warning mechanism for units.
CodeExplorer is made by our Dutch Embarcadero CodeGear Technology Partner fellow Modelmaker Tools. Prices start at EUR 99. Read more about resource string conversion with CodeExplorer on their web site.

Leave a Reply