mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-24 20:02:53 +02:00
Examples, Translation: removed GetDefaultLang reference, made TMainForm.SelectLanguage method use SetDefaultLang result
git-svn-id: trunk@61600 -
This commit is contained in:
parent
4f92041356
commit
3bbfbdcaac
@ -149,7 +149,7 @@ begin
|
|||||||
store language in a configuration file and apply that selection here. }
|
store language in a configuration file and apply that selection here. }
|
||||||
SelectLanguage('en');
|
SelectLanguage('en');
|
||||||
{ OR: Start the program with system's default language:
|
{ OR: Start the program with system's default language:
|
||||||
SelectLanguage(GetDefaultLang); }
|
SelectLanguage(''); }
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ Another example how to combine translated strings, in this case for a
|
{ Another example how to combine translated strings, in this case for a
|
||||||
@ -174,35 +174,38 @@ var
|
|||||||
lang: String;
|
lang: String;
|
||||||
begin
|
begin
|
||||||
// Switch language - this is in LCLTranslator
|
// Switch language - this is in LCLTranslator
|
||||||
SetDefaultLang(ALang);
|
ALang := SetDefaultLang(ALang);
|
||||||
|
|
||||||
// Switch default settings by calling the procedure provided in BasicLocalizedForm.pas.
|
if ALang <> '' then
|
||||||
UpdateFormatSettings(ALang);
|
begin
|
||||||
|
// Switch default settings by calling the procedure provided in BasicLocalizedForm.pas.
|
||||||
|
UpdateFormatSettings(ALang);
|
||||||
|
|
||||||
// Adjust BiDiMode to new language
|
// Adjust BiDiMode to new language
|
||||||
UpdateBiDiMode(ALang);
|
UpdateBiDiMode(ALang);
|
||||||
|
|
||||||
// Update items not automatically translated.
|
// Update items not automatically translated.
|
||||||
UpdateTranslation(ALang);
|
UpdateTranslation(ALang);
|
||||||
|
|
||||||
// Select the new language in the language combobox.
|
// Select the new language in the language combobox.
|
||||||
ALang := lowercase(ALang);
|
ALang := lowercase(ALang);
|
||||||
for i:=0 to CbLanguage.Items.Count-1 do begin
|
for i:=0 to CbLanguage.Items.Count-1 do begin
|
||||||
lang := CbLanguage.Items[i];
|
lang := CbLanguage.Items[i];
|
||||||
p := pos(' ', lang);
|
p := pos(' ', lang);
|
||||||
if p = 0 then p := pos('-', lang);
|
if p = 0 then p := pos('-', lang);
|
||||||
if p = 0 then
|
if p = 0 then
|
||||||
raise Exception.Create('Language items are not properly formatted.');
|
raise Exception.Create('Language items are not properly formatted.');
|
||||||
lang := lowercase(copy(lang, 1, p-1));
|
lang := lowercase(copy(lang, 1, p-1));
|
||||||
if lang = ALang then begin
|
if lang = ALang then begin
|
||||||
CbLanguage.ItemIndex := i;
|
CbLanguage.ItemIndex := i;
|
||||||
break;
|
break;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
|
||||||
|
|
||||||
{ Remember the new language. Forms may want to check in UpdateTranslation
|
{ Remember the new language. Forms may want to check in UpdateTranslation
|
||||||
whether the new language has a different BiDiMode. }
|
whether the new language has a different BiDiMode. }
|
||||||
CurrentLang := ALang;
|
CurrentLang := ALang;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ This method is inherited from LocalizedForm and manually inserts translated
|
{ This method is inherited from LocalizedForm and manually inserts translated
|
||||||
|
Loading…
Reference in New Issue
Block a user