Description
editLazarus Localisation Helper is an LPK, but it contains a single .pas, so it can be added to any project.
It's purpose is to make localisation easier.
1. Autodetect and apply a proper language (usually done on the first run of an app).
Example: If your OS is set to es_VE, and it happens to be unavailable, the app will select es_UY (if available), or some other es_xx.
2. Creates and handles the language selection controls - TMenuItem, TPopupMenu or TComboBox. You can use all of them simultaneously, in case you find a reason to.
3. All you you need to type is couple of lines, for example in the main form .Create procedure:
LoadLngFilesList(AppPath + 'languages'); //Adds all .PO files to the list. Replace “AppPath + 'languages'” with the folder where the PO files are stored.
CreateLanguageMenuItems(TargetControl); //Target control is TMenuItem, TPopupMenu or TComboBox which will display or handle the list of the available language. Must be created (existing) before calling CreateLanguageMenuItems.
SetLocalLanguage //Usually this is the first run of the app
{or} SetAppLang(POFileName); //if you are retrieving the language from settings.
An example app is available in the source code.
Where is it
edithttps://sourceforge.net/projects/lochelper/
It is not available in [OPM|Online_Package_Manager].
Events
editThe following events are supported:
1. OnBeforeLanguageChange
Triggerred just before the language is changed, intended use is to store properties, which might be changed by localisation, for example .ItemIndex of a combo box.
Usage :
OnBeforeLanguageChange := @DoOnBeforeLanguageChange;
2. OnLanguageChanged, triggered after the language is changed. Intended use is to restore properties affected during the change of the language, or to force localisation of properties, which are not translated atomatically, like the .Items of TComboBox.
Usage :
OnLanguageChanged := @DoLanguageChanged;
//Do some addtional things, if required, for example update combo boxes or add custom title of the main form
What else
editI localised two or three apps with it, seems to do fine so far, saves a lot of effort and time. Feedback is welcome, especially negative.