You've already forked lazarus-ccr
tvplanit: Add a single-language translation demo project.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8557 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
60
components/tvplanit/examples/localization/readme.txt
Normal file
60
components/tvplanit/examples/localization/readme.txt
Normal file
@ -0,0 +1,60 @@
|
||||
--------------------------------------------------------------------------------
|
||||
translations_demo
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
This project shows how a single-language (non-English) application with
|
||||
TvPlanIt components can be created. The example will be for a German application.
|
||||
|
||||
These are the general instructions:
|
||||
|
||||
- Create a folder "languages" for the translation files. Normally it is in the
|
||||
folder of the binary, but in order so share the translation files with other
|
||||
sample projects, we've put it in the top level of the TvPlanIt installation
|
||||
folder structure.
|
||||
|
||||
- After compilation a .pot file is created in the languages folder. Copy it and
|
||||
rename it to have the "double" extension .de.po where "de" indicates the
|
||||
German translation
|
||||
|
||||
- Install a translation tool (e.g. "poedit") and open this file in it. Translate
|
||||
all the strings to German. Save.
|
||||
|
||||
- The TvPlanIt translation files have the names vpsr.<country>.po where <country>
|
||||
is the two-digit symbol of the country, in our example: vpsr.de.po
|
||||
|
||||
- Copy the file vpsr.de.po (from (tvplanit)/languages) to the languages folder
|
||||
of the project.
|
||||
|
||||
- Copy the LCL strings file, lclstrconsts.de.po, from the lcl/languages folder
|
||||
of the Lazarus installation to the languages folder of the project.
|
||||
|
||||
- Repeat with other packages needed by the project.
|
||||
|
||||
- Add the units LCLTranslator and translations to the uses clause of the main
|
||||
form.
|
||||
|
||||
- In the OnCreate handler of the main form call the following function
|
||||
|
||||
procedure TMainForm.SelectLanguage(ALang: String);
|
||||
var
|
||||
langDir: String;
|
||||
begin
|
||||
// Calculate the path to the directory with the translation files.
|
||||
langDir := ExpandFileName(Application.Location + '../../languages/'); // Adapt to the true location of the languages folder...
|
||||
|
||||
// Switch language of the application. This is a function in LCLTranslator.
|
||||
SetDefaultLang(ALang, langDir);
|
||||
|
||||
// Translate all package string files needed.
|
||||
TranslateUnitResourceStrings('vpsr', langDir + 'vpsr.' + ALang + '.po');
|
||||
TranslateUnitResourceStrings('lclstrconsts', langDir + 'lclstrconsts.' + ALang + '.po');
|
||||
|
||||
// We must call the method LoadLanguage for all used TvPlanIt visual
|
||||
// components in order to use the translated strings in the popup menus
|
||||
// and other places not automatically handled by LCLTranslator.
|
||||
VpDayView1.LoadLanguage;
|
||||
VpWeekView1.LoadLanguage;
|
||||
VpMonthView1.LoadLanguage;
|
||||
VpTaskList1.LoadLanguage;
|
||||
VpContactGrid1.LoadLanguage;
|
||||
end;
|
Reference in New Issue
Block a user