Skip to main content
Table of Contents

TMS FNC Localization Localizer

TTMSFNCLocalizationLocalizer is the runtime engine of TMS FNC Localization. Drop it on a form or data module and it loads your translation files, switches the active application language on demand, remembers the user's choice between runs, and notifies the rest of the application when the language changes. It is a non-visual component — pair it with the String Catalog and Collector to supply and gather translatable content, and with the Localization ComboBox to let users pick a language.

Documentation

Start here Use when
Getting started You want a working language switch quickly.
User guide You want task-oriented chapters: switching, start modes, persistence, and files.
API reference You want class, property, method, and event details.

Quick start

Configure the localizer and apply the previously selected language:

Configure the localizer and apply the saved languagePascalC++
procedure TDataModule1.DataModuleCreate(Sender: TObject);
begin
  { Localizer, Collector and StringCatalog are dropped on this data module at design time. }
  Localizer.LocalizationFolder := TPath.Combine(TPath.GetDocumentsPath, 'Translations');
  Localizer.LocalizationStartMode := lsmManual;
  Localizer.PersistLanguageSelection := True;

  { The localizer already read the folder set in the Object Inspector when the
    data module loaded. The folder changed in code, so read it again. }
  Localizer.RescanLanguages;

  { Apply the language the user selected on the previous run
    (falls back to the source language when nothing was persisted). }
  Localizer.PerformLocalization;
end;
void __fastcall TDataModule1::DataModuleCreate(TObject *Sender)
{
  // Localizer, Collector and StringCatalog are dropped on this data module at design time.
  Localizer->LocalizationFolder = System::Ioutils::TPath::Combine(System::Ioutils::TPath::GetDocumentsPath(), "Translations");
  Localizer->LocalizationStartMode = TTMSFNCLocalizationStartMode::lsmManual;
  Localizer->PersistLanguageSelection = true;

  // The localizer already read the folder set in the Object Inspector when the
  // data module loaded. The folder changed in code, so read it again.
  Localizer->RescanLanguages();

  // Apply the language the user selected on the previous run
  // (falls back to the source language when nothing was persisted).
  Localizer->PerformLocalization();
}

Key classes

Class Role
TTMSFNCLocalizationLocalizer The runtime localization engine.
TTMSFNCLocalizationForm Base form that translates itself automatically in any framework.
TTMSFNCLocalizationStartMode Controls when localization is applied (manual, on idle, or automatic).
TTMSFNCLanguageFile Describes one separate language file found by the localizer's folder scan.

Guides

Guide Covers
Switching the application language TrySetLocale, OnLanguageChange, start modes, translation folders, and persisting the user's choice.
Shipping separate language files One plain-text file per language: format, lookup folders during IDE runs and after deployment, on-demand loading, and issue reporting.

See also