Lingobit Localizer - Software Localization ToolTools for software Localization DE | DA | FR | ES | IT | JA | NL | PL | PT | RU | TR | ZH
Software Localization

Lingobit Home > Solutions

Language selection for localized Delphi applications

Resource-only DLLs is a best way to create multilingual Delphi application. Software localization tool produces a set of translated resource-only DLLs. When localized application starts up, it loads one of the language DLLs and displays user interface using corresponding translations.

By default Delphi application checks the locale of the local system. If it finds any translated resource DLLs with the same name as the EXE, DLL, or BPL files it is using, it checks the extension on those DLLs. If the extension of the resource module matches the language and country of the system locale, your application will use the resources in that resource module instead of the resources in the executable, DLL, or package. If there is not a resource module that matches both the language and the country, your application will try to locate a resource module that matches just the language. If there is no resource module that matches the language, your application will use the resources compiled with the executable, DLL, or package.

If you want your localized software to use a different resource module than the one that matches the locale of the local system, you can set a locale override entry in the Windows registry. Under the HKEY_CURRENT_USER\Software\Borland\Locales key, add your application's path and file name as a string value and set the data value to the extension of your resource DLLs. At startup, the application will look for resource DLLs with this extension before trying the system locale. Setting this registry entry allows you to test localized versions of your application without changing the locale on your system.

For example, the following procedure can be used in an install or setup program to set the registry key value that indicates the locale to use when loading applications:

procedure SetLocalOverrides(FileName: string, LocaleOverride: string);
var Reg: TRegistry;
Reg := TRegistry.Create;
if Reg.OpenKey('Software\Borland\Locales', True) then
Reg.WriteString(LocalOverride, FileName);

Within your application, use the global FindResourceHInstance function to obtain the handle of the current resource module. For example:

LoadStr(FindResourceHInstance(HInstance), IDS_AmountDueName,
szQuery, SizeOf(szQuery));

You can ship a single application that adapts itself automatically to the locale of the system it is running on, simply by providing the appropriate resource DLLs.

Read more about Delphi localization in Lingobit Localizer.