IDE: display help (lazarus --help) with language specified in command line, and if it is not specified take it from IDE settings. Based on patch by Ludo Brands, bug #20099.

git-svn-id: trunk@32199 -
This commit is contained in:
maxim 2011-09-07 00:21:08 +00:00
parent 1c525dd53a
commit c14f1d3466
2 changed files with 34 additions and 1 deletions

View File

@ -61,6 +61,7 @@ function GetCommandLineParameters(aCmdLineParams : TStrings;
function IsHelpRequested (index : Integer = 1) : Boolean;
function IsVersionRequested : boolean;
function GetLanguageSpecified : string;
function ParamIsOption(ParamIndex : integer; const Option : string) : boolean;
function ParamIsOptionPlusValue(ParamIndex : integer;
const Option : string; out AValue : string) : boolean;
@ -160,6 +161,26 @@ begin
(SysUtils.CompareText (ParamStrUTF8(1), '-v') = 0));
end;
function GetLanguageSpecified : string;
var
i: integer;
AValue: string;
begin
// return language specified in command line (empty string if no language specified)
Result := '';
AValue := '';
i := 1;
while i <= ParamCount do
begin
if ParamIsOptionPlusValue(i, LanguageOpt, AValue) = true then
begin
Result := AValue;
exit;
end;
inc(i);
end;
end;
function ParamIsOption(ParamIndex : integer; const Option : string) : boolean;
begin
Result:=SysUtils.CompareText(ParamStrUTF8(ParamIndex),Option) = 0;

View File

@ -1141,6 +1141,7 @@ const
space = ' ';
var
AHelp: TStringList;
HelpLang: string;
procedure AddHelp(Args: array of const);
var
@ -1190,7 +1191,17 @@ begin
EnableRemoteControl:=false;
if IsHelpRequested then
begin
TranslateResourceStrings(ProgramDirectory(true),'');
EnvironmentOptions := nil;
HelpLang := GetLanguageSpecified;
if HelpLang <> '' then
TranslateResourceStrings(ProgramDirectory(true), HelpLang)
else
begin
EnvironmentOptions := TEnvironmentOptions.Create;
EnvironmentOptions.CreateConfig;
EnvironmentOptions.Load(true);
TranslateResourceStrings(ProgramDirectory(true), EnvironmentOptions.LanguageID);
end;
AHelp := TStringList.Create;
AddHelp([lislazarusOptionsProjectFilename]);
@ -1237,6 +1248,7 @@ begin
WriteHelp(AHelp.Text);
AHelp.Free;
FreeThenNil(EnvironmentOptions);
exit;
end;
if IsVersionRequested then