Table of Contents

Getting started with the String Catalog

This page covers the shortest path to storing a translatable string and reading it back in the active language. For the full details — adding entries, enumerating them, and keeping code-driven text in sync — see the user guide.

Prerequisites

  • TMS FNC Core installed and the runtime package added to the project.
  • TMS FNC Localization installed.

Add the component

Drop a TTMSFNCLocalizationStringCatalog from the TMS FNC Localization palette tab — usually onto the same data module as the localizer, so it is shared across forms. Add named entries (a Name and a default Value) at design time through the Strings collection editor, or in code:

procedure TForm1.FormCreate(Sender: TObject);
var
  Entry: TTMSFNCLocalizationString;
begin
  { Entries are usually added at design time; shown here in code. }
  Entry := StringCatalog.Strings.Add;
  Entry.Name := 'Greeting';
  Entry.Value := 'Hello';
end;

procedure TForm1.SayHello;
begin
  { Returns the value for 'Greeting' in the currently active language
    (empty string when no entry has that name). }
  ShowMessage(StringCatalog.GetByName('Greeting'));
end;

Look up a string

At runtime, call GetByName with an entry's name to get its value in the currently active language. It returns an empty string when no entry has that name, so you can fall back gracefully. Once the entries are translated (with the Localization Editor) and a language is active, the same call returns the translated text.

See also