TjanLanguage is a TComponent descendant that allows you to give the users of your program the ability to change all captions,text and hints of any component in the user interface like menus, buttons, labels, listbox items etc. All this with only 2 lines of code!
This component is an orginal Delphi component created by Jan Verhoeven and offered as freeware for free use in any application including commercial applications. You are free to copy and modify the source code provided you do not remove the originator comments.
The component is designed for minimal coding:
janLanguage1.InitLanguage(self)
janLanguage1.ChangeLanguage(self)
That is all!
This will look in the ini file for the language file to use and will set captions, hints and text accordingly when found. In addition this method call will create/refresh the Language.lng file.
If no language entry is found the default Language.lng will be used.
procedure ChangeLanguage(AForm:Tform);This will show a file open dialog for the user to select a language file. If a language file is selected it will be loaded and all captions, text, hints etc will be set according the language file. In addition the name of the selected language file is stored in the programs ini file.
Language Files are in fact ini files with one section: [TRANSLATIONS], and possibly a whole range of section values.
The general form of each entry in the language file is:
FormName.ComponentName.PropertyName=PropertyValue
You will understand that when you use this component in your programs and that when you use component names like 'button1','label3', etc. you are making it not easy for your users to create their own language files. Use very descriptive component names.
Your users will typically create a renamed copy of the Language.lng file and modify the PropertyValue parts in e.g. Windows Notepad.
Any carriage returns in captions, text or hints is replaced by '~~' when written to the language file and reverted to cariage returns when read from the language file.