IDE: initial setup dialog: translate captions and lcl

git-svn-id: trunk@42745 -
This commit is contained in:
mattias 2013-09-11 23:30:16 +00:00
parent 923b055a1f
commit d6191d3f6b
5 changed files with 74 additions and 44 deletions

View File

@ -68,13 +68,13 @@ type
PPOFile = ^TPOFile; PPOFile = ^TPOFile;
// translate all resource strings // translate all resource strings
procedure TranslateResourceStrings(const BaseDirectory, CustomLang: string); procedure TranslateResourceStrings(const LazarusDir, CustomLang: string);
// get language name for ID // get language name for ID
function GetLazarusLanguageLocalizedName(const ID: string): String; function GetLazarusLanguageLocalizedName(const ID: string): String;
// collect all available translations // collect all available translations
procedure CollectTranslations(const LazarusDir: string); procedure CollectTranslations(const LazarusDir: string); // this updates LazarusTranslations
function ConvertRSTFiles(RSTDirectory, PODirectory: string; function ConvertRSTFiles(RSTDirectory, PODirectory: string;
POFilename: string = '' // set POFilename to gather all rst into one po file POFilename: string = '' // set POFilename to gather all rst into one po file
@ -87,7 +87,7 @@ function FindTranslatedPoFiles(const BasePOFilename: string): TStringList;
procedure UpdateTranslatedPoFile(const BasePOFile: TPOFile; TranslatedFilename: string); procedure UpdateTranslatedPoFile(const BasePOFile: TPOFile; TranslatedFilename: string);
var var
LazarusTranslations: TLazarusTranslations = nil; LazarusTranslations: TLazarusTranslations = nil; // see CollectTranslations
SystemLanguageID1, SystemLanguageID2: string; SystemLanguageID1, SystemLanguageID2: string;
implementation implementation
@ -432,15 +432,14 @@ end;
- gdbmidebugger.pp - gdbmidebugger.pp
- debuggerstrconst.pp - debuggerstrconst.pp
-------------------------------------------------------------------------------} -------------------------------------------------------------------------------}
procedure TranslateResourceStrings(const BaseDirectory, CustomLang: string); procedure TranslateResourceStrings(const LazarusDir, CustomLang: string);
const const
Ext = '.%s.po'; Ext = '.%s.po';
var var
Lang, FallbackLang: String; Lang, FallbackLang: String;
Dir: String; Dir: String;
begin begin
//debugln('TranslateResourceStrings A CustomLang=',CustomLang); if LazarusTranslations=nil then CollectTranslations(LazarusDir);
if LazarusTranslations=nil then CollectTranslations(BaseDirectory);
if CustomLang='' then begin if CustomLang='' then begin
Lang:=SystemLanguageID1; Lang:=SystemLanguageID1;
FallbackLang:=SystemLanguageID2; FallbackLang:=SystemLanguageID2;
@ -448,8 +447,8 @@ begin
Lang:=CustomLang; Lang:=CustomLang;
FallbackLang:=''; FallbackLang:='';
end; end;
//debugln('TranslateResourceStrings A Lang=',Lang,' FallbackLang=',FallbackLang); debugln('TranslateResourceStrings A Lang=',Lang,' FallbackLang=',FallbackLang);
Dir:=AppendPathDelim(BaseDirectory); Dir:=AppendPathDelim(LazarusDir);
// IDE // IDE
TranslateUnitResourceStrings('LazarusIDEStrConsts', TranslateUnitResourceStrings('LazarusIDEStrConsts',
Dir+'languages/lazaruside'+Ext,Lang,FallbackLang); Dir+'languages/lazaruside'+Ext,Lang,FallbackLang);
@ -459,6 +458,9 @@ begin
// Debugger GUI // Debugger GUI
TranslateUnitResourceStrings('DebuggerStrConst', TranslateUnitResourceStrings('DebuggerStrConst',
Dir+'languages/debuggerstrconst'+Ext,Lang,FallbackLang); Dir+'languages/debuggerstrconst'+Ext,Lang,FallbackLang);
// LCL
TranslateUnitResourceStrings('LCLStrConsts',
Dir+'lcl/languages/lclstrconsts'+Ext,Lang,FallbackLang);
end; end;
{ TLazarusTranslations } { TLazarusTranslations }

View File

@ -46,7 +46,7 @@ uses
Dialogs, FileUtil, Laz2_XMLCfg, lazutf8classes, LazFileUtils, Graphics, Dialogs, FileUtil, Laz2_XMLCfg, lazutf8classes, LazFileUtils, Graphics,
ComCtrls, ExtCtrls, StdCtrls, DefineTemplates, CodeToolManager, ComCtrls, ExtCtrls, StdCtrls, DefineTemplates, CodeToolManager,
TransferMacros, MacroDefIntf, LazarusIDEStrConsts, LazConf, EnvironmentOpts, TransferMacros, MacroDefIntf, LazarusIDEStrConsts, LazConf, EnvironmentOpts,
IDEProcs, AboutFrm; IDEProcs, AboutFrm, IDETranslations;
type type
TSDFilenameQuality = ( TSDFilenameQuality = (
@ -185,6 +185,7 @@ type
FSelectingPage: boolean; FSelectingPage: boolean;
FCandidates: array[TSDFilenameType] of TSDFileInfoList; // list of TSDFileInfo FCandidates: array[TSDFilenameType] of TSDFileInfoList; // list of TSDFileInfo
fSearchFpcSourceThread: TSearchFpcSourceThread; fSearchFpcSourceThread: TSearchFpcSourceThread;
procedure UpdateCaptions;
procedure SelectPage(const NodeText: string); procedure SelectPage(const NodeText: string);
function SelectDirectory(aTitle: string): string; function SelectDirectory(aTitle: string): string;
procedure StartFPCSrcThread; procedure StartFPCSrcThread;
@ -209,6 +210,7 @@ type
function QualityToImgIndex(Quality: TSDFilenameQuality): integer; function QualityToImgIndex(Quality: TSDFilenameQuality): integer;
procedure ShowHideScanControls(aShow: Boolean); procedure ShowHideScanControls(aShow: Boolean);
procedure ThreadTerminated(Sender: TObject); // called in main thread by fSearchFpcSourceThread.OnTerminate procedure ThreadTerminated(Sender: TObject); // called in main thread by fSearchFpcSourceThread.OnTerminate
procedure TranslateResourceStrings;
public public
TVNodeLazarus: TTreeNode; TVNodeLazarus: TTreeNode;
TVNodeCompiler: TTreeNode; TVNodeCompiler: TTreeNode;
@ -1343,13 +1345,7 @@ end;
{ TInitialSetupDialog } { TInitialSetupDialog }
procedure TInitialSetupDialog.FormCreate(Sender: TObject); procedure TInitialSetupDialog.FormCreate(Sender: TObject);
var
s: String;
begin begin
Caption:=Format(lisWelcomeToLazarusIDE, [GetLazarusVersionString]);
StartIDEBitBtn.Caption:=lisStartIDE;
LazarusTabSheet.Caption:='Lazarus'; LazarusTabSheet.Caption:='Lazarus';
CompilerTabSheet.Caption:=lisCompiler; CompilerTabSheet.Caption:=lisCompiler;
FPCSourcesTabSheet.Caption:=lisFPCSources; FPCSourcesTabSheet.Caption:=lisFPCSources;
@ -1367,34 +1363,9 @@ begin
ImgIDError := ImageList1.AddLazarusResource('state_error'); ImgIDError := ImageList1.AddLazarusResource('state_error');
ImgIDWarning := ImageList1.AddLazarusResource('state_warning'); ImgIDWarning := ImageList1.AddLazarusResource('state_warning');
LazDirBrowseButton.Caption:=lisPathEditBrowse;
LazDirLabel.Caption:=Format(
lisTheLazarusDirectoryContainsTheSourcesOfTheIDEAndTh, [PathDelim]);
CompilerBrowseButton.Caption:=lisPathEditBrowse;
CompilerLabel.Caption:=Format(lisTheFreePascalCompilerExecutableTypicallyHasTheName,
[DefineTemplates.GetDefaultCompilerFilename,
DefineTemplates.GetDefaultCompilerFilename(GetCompiledTargetCPU)]);
FPCSrcDirBrowseButton.Caption:=lisPathEditBrowse;
FPCSrcDirLabel.Caption:=Format(lisTheSourcesOfTheFreePascalPackagesAreRequiredForBro,
[SetDirSeparators('rtl/linux/system.pp')]);
// Scanning the file system in search of FPC sources
ScanLabel.Caption := lisScanning;
StopScanButton.Caption:=lisStop;
StopScanButton.LoadGlyphFromLazarusResource('menu_stop'); StopScanButton.LoadGlyphFromLazarusResource('menu_stop');
MakeExeBrowseButton.Caption:=lisPathEditBrowse; UpdateCaptions;
MakeExeLabel.Caption:=Format(
lisTheMakeExecutableTypicallyHasTheName, ['make'+GetExecutableExt('')]);
DebuggerBrowseButton.Caption:=lisPathEditBrowse;
s:=Format(lisTheDebuggerExecutableTypicallyHasTheNamePleaseGive, [
'gdb'+GetExecutableExt]);
{$IFDEF Windows}
s+=' '+lisAUsefulSettingOnWindowsSystemsIsLazarusDirMingwBin;
{$ENDIF}
DebuggerLabel.Caption:=s;
Application.AddOnActivateHandler(@OnAppActivate); Application.AddOnActivateHandler(@OnAppActivate);
end; end;
@ -1638,6 +1609,54 @@ begin
IdleConnected:=false; IdleConnected:=false;
end; end;
procedure TInitialSetupDialog.UpdateCaptions;
var
s: String;
begin
Caption:=Format(lisWelcomeToLazarusIDE, [GetLazarusVersionString]);
StartIDEBitBtn.Caption:=lisStartIDE;
LazarusTabSheet.Caption:='Lazarus';
CompilerTabSheet.Caption:=lisCompiler;
FPCSourcesTabSheet.Caption:=lisFPCSources;
MakeExeTabSheet.Caption:='Make';
DebuggerTabSheet.Caption:=lisDebugger;
TVNodeLazarus.Text:=LazarusTabSheet.Caption;
TVNodeCompiler.Text:=CompilerTabSheet.Caption;
TVNodeFPCSources.Text:=FPCSourcesTabSheet.Caption;
TVNodeMakeExe.Text:=MakeExeTabSheet.Caption;
TVNodeDebugger.Text:=DebuggerTabSheet.Caption;
LazDirBrowseButton.Caption:=lisPathEditBrowse;
LazDirLabel.Caption:=Format(
lisTheLazarusDirectoryContainsTheSourcesOfTheIDEAndTh, [PathDelim]);
CompilerBrowseButton.Caption:=lisPathEditBrowse;
CompilerLabel.Caption:=Format(lisTheFreePascalCompilerExecutableTypicallyHasTheName,
[DefineTemplates.GetDefaultCompilerFilename,
DefineTemplates.GetDefaultCompilerFilename(GetCompiledTargetCPU)]);
FPCSrcDirBrowseButton.Caption:=lisPathEditBrowse;
FPCSrcDirLabel.Caption:=Format(lisTheSourcesOfTheFreePascalPackagesAreRequiredForBro,
[SetDirSeparators('rtl/linux/system.pp')]);
ScanLabel.Caption := lisScanning;
StopScanButton.Caption:=lisStop;
MakeExeBrowseButton.Caption:=lisPathEditBrowse;
MakeExeLabel.Caption:=Format(
lisTheMakeExecutableTypicallyHasTheName, ['make'+GetExecutableExt('')]);
DebuggerBrowseButton.Caption:=lisPathEditBrowse;
s:=Format(lisTheDebuggerExecutableTypicallyHasTheNamePleaseGive, [
'gdb'+GetExecutableExt]);
{$IFDEF Windows}
s+=' '+lisAUsefulSettingOnWindowsSystemsIsLazarusDirMingwBin;
{$ENDIF}
DebuggerLabel.Caption:=s;
end;
procedure TInitialSetupDialog.SelectPage(const NodeText: string); procedure TInitialSetupDialog.SelectPage(const NodeText: string);
var var
i: Integer; i: Integer;
@ -2025,6 +2044,14 @@ begin
ShowHideScanControls(false); ShowHideScanControls(false);
end; end;
procedure TInitialSetupDialog.TranslateResourceStrings;
begin
IDETranslations.TranslateResourceStrings(
EnvironmentOptions.GetParsedLazarusDirectory,
EnvironmentOptions.LanguageID);
UpdateCaptions;
end;
procedure TInitialSetupDialog.Init; procedure TInitialSetupDialog.Init;
var var
Node: TTreeNode; Node: TTreeNode;
@ -2072,6 +2099,8 @@ begin
Candidate:=GetFirstCandidate(FCandidates[sddtLazarusSrcDir]); Candidate:=GetFirstCandidate(FCandidates[sddtLazarusSrcDir]);
if Candidate<>nil then if Candidate<>nil then
EnvironmentOptions.LazarusDirectory:=Candidate.Caption; EnvironmentOptions.LazarusDirectory:=Candidate.Caption;
if FileExistsCached(EnvironmentOptions.GetParsedLazarusDirectory) then
TranslateResourceStrings;
end; end;
LazDirComboBox.Text:=EnvironmentOptions.LazarusDirectory; LazDirComboBox.Text:=EnvironmentOptions.LazarusDirectory;
FLastParsedLazDir:='. .'; FLastParsedLazDir:='. .';

View File

@ -1283,7 +1283,6 @@ begin
end; end;
if Application.HasOption('language') then if Application.HasOption('language') then
begin begin
debugln('TMainIDE.LoadGlobalOptions overriding language with command line: ', debugln('TMainIDE.LoadGlobalOptions overriding language with command line: ',

View File

@ -410,7 +410,6 @@ begin
if (ResUnitName='') or (BaseFilename='') then if (ResUnitName='') or (BaseFilename='') then
Result:=turEmptyParam //Result: empty Parameter Result:=turEmptyParam //Result: empty Parameter
else begin else begin
//debugln('TranslateUnitResourceStrings BaseFilename="',BaseFilename,'"');
if (FallbackLang<>'') and FileExistsUTF8(Format(BaseFilename,[FallbackLang])) then if (FallbackLang<>'') and FileExistsUTF8(Format(BaseFilename,[FallbackLang])) then
TranslateUnitResourceStrings(ResUnitName,Format(BaseFilename,[FallbackLang])) TranslateUnitResourceStrings(ResUnitName,Format(BaseFilename,[FallbackLang]))
else else

View File

@ -1863,8 +1863,9 @@ var
if CompareFileExt(Filename,'.po',false)<>0 then continue; if CompareFileExt(Filename,'.po',false)<>0 then continue;
if GetPOFilenameParts(Filename,CurUnitName,CurLang) if GetPOFilenameParts(Filename,CurUnitName,CurLang)
and (CurLang=Language) and (CurLang=Language)
and (not UnitTranslated(CurUnitName))
and (APackage.FindUnit(CurUnitName)<>nil) and (APackage.FindUnit(CurUnitName)<>nil)
and not UnitTranslated(CurUnitName) then begin then begin
TranslateUnit(AppendPathDelim(Directory)+Filename,CurUnitName); TranslateUnit(AppendPathDelim(Directory)+Filename,CurUnitName);
end; end;
end; end;