mirror of
				https://gitlab.com/freepascal.org/lazarus/lazarus.git
				synced 2025-11-04 10:39:53 +01:00 
			
		
		
		
	IDE: initial setup dialog: translate captions and lcl
git-svn-id: trunk@42745 -
This commit is contained in:
		
							parent
							
								
									923b055a1f
								
							
						
					
					
						commit
						d6191d3f6b
					
				@ -68,13 +68,13 @@ type
 | 
			
		||||
  PPOFile = ^TPOFile;
 | 
			
		||||
  
 | 
			
		||||
// translate all resource strings
 | 
			
		||||
procedure TranslateResourceStrings(const BaseDirectory, CustomLang: string);
 | 
			
		||||
procedure TranslateResourceStrings(const LazarusDir, CustomLang: string);
 | 
			
		||||
 | 
			
		||||
// get language name for ID
 | 
			
		||||
function GetLazarusLanguageLocalizedName(const ID: string): String;
 | 
			
		||||
 | 
			
		||||
// collect all available translations
 | 
			
		||||
procedure CollectTranslations(const LazarusDir: string);
 | 
			
		||||
procedure CollectTranslations(const LazarusDir: string); // this updates LazarusTranslations
 | 
			
		||||
 | 
			
		||||
function ConvertRSTFiles(RSTDirectory, PODirectory: string;
 | 
			
		||||
  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);
 | 
			
		||||
 | 
			
		||||
var
 | 
			
		||||
  LazarusTranslations: TLazarusTranslations = nil;
 | 
			
		||||
  LazarusTranslations: TLazarusTranslations = nil; // see CollectTranslations
 | 
			
		||||
  SystemLanguageID1, SystemLanguageID2: string;
 | 
			
		||||
 | 
			
		||||
implementation
 | 
			
		||||
@ -432,15 +432,14 @@ end;
 | 
			
		||||
    - gdbmidebugger.pp
 | 
			
		||||
    - debuggerstrconst.pp
 | 
			
		||||
-------------------------------------------------------------------------------}
 | 
			
		||||
procedure TranslateResourceStrings(const BaseDirectory, CustomLang: string);
 | 
			
		||||
procedure TranslateResourceStrings(const LazarusDir, CustomLang: string);
 | 
			
		||||
const
 | 
			
		||||
  Ext = '.%s.po';
 | 
			
		||||
var
 | 
			
		||||
  Lang, FallbackLang: String;
 | 
			
		||||
  Dir: String;
 | 
			
		||||
begin
 | 
			
		||||
  //debugln('TranslateResourceStrings A CustomLang=',CustomLang);
 | 
			
		||||
  if LazarusTranslations=nil then CollectTranslations(BaseDirectory);
 | 
			
		||||
  if LazarusTranslations=nil then CollectTranslations(LazarusDir);
 | 
			
		||||
  if CustomLang='' then begin
 | 
			
		||||
    Lang:=SystemLanguageID1;
 | 
			
		||||
    FallbackLang:=SystemLanguageID2;
 | 
			
		||||
@ -448,8 +447,8 @@ begin
 | 
			
		||||
    Lang:=CustomLang;
 | 
			
		||||
    FallbackLang:='';
 | 
			
		||||
  end;
 | 
			
		||||
  //debugln('TranslateResourceStrings A Lang=',Lang,' FallbackLang=',FallbackLang);
 | 
			
		||||
  Dir:=AppendPathDelim(BaseDirectory);
 | 
			
		||||
  debugln('TranslateResourceStrings A Lang=',Lang,' FallbackLang=',FallbackLang);
 | 
			
		||||
  Dir:=AppendPathDelim(LazarusDir);
 | 
			
		||||
  // IDE
 | 
			
		||||
  TranslateUnitResourceStrings('LazarusIDEStrConsts',
 | 
			
		||||
    Dir+'languages/lazaruside'+Ext,Lang,FallbackLang);
 | 
			
		||||
@ -459,6 +458,9 @@ begin
 | 
			
		||||
  // Debugger GUI
 | 
			
		||||
  TranslateUnitResourceStrings('DebuggerStrConst',
 | 
			
		||||
    Dir+'languages/debuggerstrconst'+Ext,Lang,FallbackLang);
 | 
			
		||||
  // LCL
 | 
			
		||||
  TranslateUnitResourceStrings('LCLStrConsts',
 | 
			
		||||
    Dir+'lcl/languages/lclstrconsts'+Ext,Lang,FallbackLang);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
{ TLazarusTranslations }
 | 
			
		||||
 | 
			
		||||
@ -46,7 +46,7 @@ uses
 | 
			
		||||
  Dialogs, FileUtil, Laz2_XMLCfg, lazutf8classes, LazFileUtils, Graphics,
 | 
			
		||||
  ComCtrls, ExtCtrls, StdCtrls, DefineTemplates, CodeToolManager,
 | 
			
		||||
  TransferMacros, MacroDefIntf, LazarusIDEStrConsts, LazConf, EnvironmentOpts,
 | 
			
		||||
  IDEProcs, AboutFrm;
 | 
			
		||||
  IDEProcs, AboutFrm, IDETranslations;
 | 
			
		||||
  
 | 
			
		||||
type
 | 
			
		||||
  TSDFilenameQuality = (
 | 
			
		||||
@ -185,6 +185,7 @@ type
 | 
			
		||||
    FSelectingPage: boolean;
 | 
			
		||||
    FCandidates: array[TSDFilenameType] of TSDFileInfoList; // list of TSDFileInfo
 | 
			
		||||
    fSearchFpcSourceThread: TSearchFpcSourceThread;
 | 
			
		||||
    procedure UpdateCaptions;
 | 
			
		||||
    procedure SelectPage(const NodeText: string);
 | 
			
		||||
    function SelectDirectory(aTitle: string): string;
 | 
			
		||||
    procedure StartFPCSrcThread;
 | 
			
		||||
@ -209,6 +210,7 @@ type
 | 
			
		||||
    function QualityToImgIndex(Quality: TSDFilenameQuality): integer;
 | 
			
		||||
    procedure ShowHideScanControls(aShow: Boolean);
 | 
			
		||||
    procedure ThreadTerminated(Sender: TObject); // called in main thread by fSearchFpcSourceThread.OnTerminate
 | 
			
		||||
    procedure TranslateResourceStrings;
 | 
			
		||||
  public
 | 
			
		||||
    TVNodeLazarus: TTreeNode;
 | 
			
		||||
    TVNodeCompiler: TTreeNode;
 | 
			
		||||
@ -1343,13 +1345,7 @@ end;
 | 
			
		||||
{ TInitialSetupDialog }
 | 
			
		||||
 | 
			
		||||
procedure TInitialSetupDialog.FormCreate(Sender: TObject);
 | 
			
		||||
var
 | 
			
		||||
  s: String;
 | 
			
		||||
begin
 | 
			
		||||
  Caption:=Format(lisWelcomeToLazarusIDE, [GetLazarusVersionString]);
 | 
			
		||||
 | 
			
		||||
  StartIDEBitBtn.Caption:=lisStartIDE;
 | 
			
		||||
 | 
			
		||||
  LazarusTabSheet.Caption:='Lazarus';
 | 
			
		||||
  CompilerTabSheet.Caption:=lisCompiler;
 | 
			
		||||
  FPCSourcesTabSheet.Caption:=lisFPCSources;
 | 
			
		||||
@ -1367,34 +1363,9 @@ begin
 | 
			
		||||
  ImgIDError := ImageList1.AddLazarusResource('state_error');
 | 
			
		||||
  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');
 | 
			
		||||
 | 
			
		||||
  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;
 | 
			
		||||
  UpdateCaptions;
 | 
			
		||||
 | 
			
		||||
  Application.AddOnActivateHandler(@OnAppActivate);
 | 
			
		||||
end;
 | 
			
		||||
@ -1638,6 +1609,54 @@ begin
 | 
			
		||||
    IdleConnected:=false;
 | 
			
		||||
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);
 | 
			
		||||
var
 | 
			
		||||
  i: Integer;
 | 
			
		||||
@ -2025,6 +2044,14 @@ begin
 | 
			
		||||
  ShowHideScanControls(false);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TInitialSetupDialog.TranslateResourceStrings;
 | 
			
		||||
begin
 | 
			
		||||
  IDETranslations.TranslateResourceStrings(
 | 
			
		||||
                           EnvironmentOptions.GetParsedLazarusDirectory,
 | 
			
		||||
                           EnvironmentOptions.LanguageID);
 | 
			
		||||
  UpdateCaptions;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TInitialSetupDialog.Init;
 | 
			
		||||
var
 | 
			
		||||
  Node: TTreeNode;
 | 
			
		||||
@ -2072,6 +2099,8 @@ begin
 | 
			
		||||
    Candidate:=GetFirstCandidate(FCandidates[sddtLazarusSrcDir]);
 | 
			
		||||
    if Candidate<>nil then
 | 
			
		||||
      EnvironmentOptions.LazarusDirectory:=Candidate.Caption;
 | 
			
		||||
    if FileExistsCached(EnvironmentOptions.GetParsedLazarusDirectory) then
 | 
			
		||||
      TranslateResourceStrings;
 | 
			
		||||
  end;
 | 
			
		||||
  LazDirComboBox.Text:=EnvironmentOptions.LazarusDirectory;
 | 
			
		||||
  FLastParsedLazDir:='. .';
 | 
			
		||||
 | 
			
		||||
@ -1283,7 +1283,6 @@ begin
 | 
			
		||||
    end;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    if Application.HasOption('language') then
 | 
			
		||||
    begin
 | 
			
		||||
      debugln('TMainIDE.LoadGlobalOptions overriding language with command line: ',
 | 
			
		||||
 | 
			
		||||
@ -410,7 +410,6 @@ begin
 | 
			
		||||
  if (ResUnitName='') or (BaseFilename='') then
 | 
			
		||||
    Result:=turEmptyParam       //Result: empty Parameter
 | 
			
		||||
  else begin
 | 
			
		||||
    //debugln('TranslateUnitResourceStrings BaseFilename="',BaseFilename,'"');
 | 
			
		||||
    if (FallbackLang<>'') and FileExistsUTF8(Format(BaseFilename,[FallbackLang])) then
 | 
			
		||||
      TranslateUnitResourceStrings(ResUnitName,Format(BaseFilename,[FallbackLang]))
 | 
			
		||||
    else
 | 
			
		||||
 | 
			
		||||
@ -1863,8 +1863,9 @@ var
 | 
			
		||||
        if CompareFileExt(Filename,'.po',false)<>0 then continue;
 | 
			
		||||
        if GetPOFilenameParts(Filename,CurUnitName,CurLang)
 | 
			
		||||
        and (CurLang=Language)
 | 
			
		||||
        and (not UnitTranslated(CurUnitName))
 | 
			
		||||
        and (APackage.FindUnit(CurUnitName)<>nil)
 | 
			
		||||
        and not UnitTranslated(CurUnitName) then begin
 | 
			
		||||
        then begin
 | 
			
		||||
          TranslateUnit(AppendPathDelim(Directory)+Filename,CurUnitName);
 | 
			
		||||
        end;
 | 
			
		||||
      end;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user