Skip to content

EF.Localization

This unit defines an interface for localization libraries to plug into. All the units in EF send their strings to this stub, which in turn directs them to whatever localization tool is used to localize an application.@br To plug a localization tool, you need to implement IEFLocalizationTool in a class of your choice and register it by calling TEFLocalizationToolRegistry.RegisterLocalizationTool. This is usually done in a unit's initialization section.

IEFLocalizationTool interface

The localization tool interface.

pascal
function TranslateString(const AString: string;

Translates a string in the default language to a string in the current language. Some tools file strings giving an Id to each of them. A particular tool might require you to pass AIdString, an opaque string that uniquely identifies the string to translate.

pascal
procedure TranslateComponent(const AComponent: TComponent);

Translates all the string properties in Component and all the components it owns from the default language to the current language. It is usually called for each dfm-based form that is created.

pascal
procedure ForceLanguage(const ALanguageId: string);

Forces the use of a particular language instead of the system default.

pascal
function GetCurrentLanguageId: string;

Returns the Id of the currently used language.

TEFLocalizationToolRegistry class

Keeps track of the currently active localization tool.

pascal
class procedure RegisterTool(const ATool: IEFLocalizationTool);

Sets the current tool to ATool. Pass nil to set the current tool back to the default tool.

pascal
class procedure UnregisterTool;

Same as RegisterTool(nil);

TEFNullLocalizationTool class

This class implements the default localization tool, which does nothing.

pascal
function AsObject: TObject;

Returns the implementing object (Self).

pascal
function TranslateString(const AString: string;

Returns AString unchanged (no translation is performed).

pascal
procedure TranslateComponent(const AComponent: TComponent);

Does nothing (no translation is performed).

pascal
procedure ForceLanguage(const ALanguageId: string);

Does nothing (no language switching is performed).

pascal
function GetCurrentLanguageId: string;

Returns '' (no current language is tracked).

Routines

pascal
function TranslateString(const AString: string;

Shortcut for TEFLocalizationToolRegistry.CurrentTool.TranslateString.

Parameters:

  • AString — String to translate. If the string is enclosed by '_(' and ')', these characters are stripped.
pascal
function _(const AString: string;

Shortcut for TEFLocalizationToolRegistry.CurrentTool.TranslateString.

Parameters:

  • AString — String to translate. If the string is enclosed by '_(' and ')', these characters are stripped.

Released under Apache License, Version 2.0.