IDE: option to disable i18n for lfm files of project

git-svn-id: trunk@26167 -
This commit is contained in:
mattias 2010-06-18 07:49:33 +00:00
parent e2f67c6c10
commit 8d3b3406e6
6 changed files with 109 additions and 25 deletions

View File

@ -1,40 +1,43 @@
inherited ProjectI18NOptionsFrame: TProjectI18NOptionsFrame
Height = 177
Height = 242
Width = 438
ClientHeight = 177
ClientHeight = 242
ClientWidth = 438
OnClick = FrameClick
TabOrder = 0
DesignLeft = 467
DesignTop = 355
object EnableI18NCheckBox: TCheckBox[0]
Left = 0
Height = 17
Height = 22
Top = 0
Width = 438
Align = alTop
Caption = 'Enable i18n'
OnChange = EnableI18NCheckBoxChange
ParentShowHint = False
ShowHint = True
TabOrder = 0
end
object I18NGroupBox: TGroupBox[1]
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
Left = 0
Height = 73
Top = 23
Height = 112
Top = 28
Width = 438
Align = alTop
AutoSize = True
BorderSpacing.Top = 6
Caption = 'i18n Options'
ClientHeight = 55
ClientWidth = 434
ClientHeight = 94
ClientWidth = 430
TabOrder = 1
object PoOutDirLabel: TLabel
Left = 6
Height = 14
Height = 18
Top = 6
Width = 103
Width = 134
BorderSpacing.Around = 6
Caption = 'PO Output Directory:'
ParentColor = False
@ -45,13 +48,15 @@ inherited ProjectI18NOptionsFrame: TProjectI18NOptionsFrame
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = POOutDirButton
Left = 6
Height = 21
Top = 26
Width = 398
Height = 27
Top = 30
Width = 394
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6
BorderSpacing.Top = 6
BorderSpacing.Bottom = 6
ParentShowHint = False
ShowHint = True
TabOrder = 0
Text = 'POOutDirEdit'
end
@ -61,9 +66,9 @@ inherited ProjectI18NOptionsFrame: TProjectI18NOptionsFrame
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = POOutDirEdit
AnchorSideBottom.Side = asrBottom
Left = 404
Height = 21
Top = 26
Left = 400
Height = 27
Top = 30
Width = 24
Anchors = [akTop, akRight, akBottom]
BorderSpacing.Right = 6
@ -71,5 +76,19 @@ inherited ProjectI18NOptionsFrame: TProjectI18NOptionsFrame
OnClick = POOutDirButtonClick
TabOrder = 1
end
object PoForFormsCheckBox: TCheckBox
AnchorSideLeft.Control = PoOutDirLabel
AnchorSideTop.Control = POOutDirEdit
AnchorSideTop.Side = asrBottom
Left = 6
Height = 22
Top = 72
Width = 171
BorderSpacing.Top = 15
Caption = 'PoForFormsCheckBox'
ParentShowHint = False
ShowHint = True
TabOrder = 2
end
end
end

View File

@ -15,10 +15,12 @@ type
TProjectI18NOptionsFrame = class(TAbstractIDEOptionsEditor)
EnableI18NCheckBox: TCheckBox;
I18NGroupBox: TGroupBox;
PoForFormsCheckBox: TCheckBox;
POOutDirButton: TButton;
POOutDirEdit: TEdit;
PoOutDirLabel: TLabel;
procedure EnableI18NCheckBoxChange(Sender: TObject);
procedure FrameClick(Sender: TObject);
procedure POOutDirButtonClick(Sender: TObject);
private
FProject: TProject;
@ -42,6 +44,11 @@ begin
Enablei18nInfo(EnableI18NCheckBox.Checked);
end;
procedure TProjectI18NOptionsFrame.FrameClick(Sender: TObject);
begin
end;
procedure TProjectI18NOptionsFrame.POOutDirButtonClick(Sender: TObject);
var
NewDirectory: string;
@ -67,8 +74,13 @@ end;
procedure TProjectI18NOptionsFrame.Setup(ADialog: TAbstractOptionsEditorDialog);
begin
EnableI18NCheckBox.Caption := rsEnableI18n;
EnableI18NCheckBox.Hint:=lisEnableInternationalizationAndTranslationSupport;
I18NGroupBox.Caption := rsI18nOptions;
PoOutDirLabel.Caption := rsPOOutputDirectory;
POOutDirEdit.Hint:=lisDirectoryWhereTheIDEPutsThePoFiles;
PoForFormsCheckBox.Caption:=lisCreateUpdatePoFileWhenSavingALfmFile;
PoForFormsCheckBox.Hint:=
lisYouCanDisableThisForIndividualFormsViaThePopupMenu;
end;
procedure TProjectI18NOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions);
@ -83,6 +95,7 @@ begin
AFilename:=CreateRelativePath(AFilename,FProject.ProjectDirectory);
POOutDirEdit.Text := AFilename;
EnableI18NCheckBox.Checked := Enablei18n;
PoForFormsCheckBox.Checked:=EnableI18NForLFM;
Enablei18nInfo(Enablei18n);
end;
end;
@ -98,6 +111,7 @@ begin
AFilename:=AppendPathDelim(ProjectDirectory)+AFilename;
POOutputDirectory := AFilename;
EnableI18N := EnableI18NCheckBox.Checked;
EnableI18NForLFM := PoForFormsCheckBox.Checked;
end;
end;

View File

@ -1951,8 +1951,17 @@ resourcestring
dlgPOMisc = 'Miscellaneous';
dlgPOI18n = 'i18n';
rsEnableI18n = 'Enable i18n';
lisEnableInternationalizationAndTranslationSupport = 'Enable internationaliza'
+'tion and translation support';
rsI18nOptions = 'i18n Options';
rsPOOutputDirectory = 'PO Output Directory:';
lisDirectoryWhereTheIDEPutsThePoFiles = 'Directory where the IDE puts the .'
+'po files';
lisCreateUpdatePoFileWhenSavingALfmFile = 'Create/update .po file when '
+'saving a lfm file';
lisYouCanDisableThisForIndividualFormsViaThePopupMenu = 'You can disable '
+'this for individual forms via the popup menu in the source editor, file '
+'settings, i18n for lfm strings';
rsIncludeVersionInfoInExecutable = 'Include Version Info in executable';
rsVersionNumbering = 'Version numbering';
rsMajorVersion = '&Major version:';
@ -2153,6 +2162,7 @@ resourcestring
uemReadOnly = 'Read Only';
uemShowLineNumbers = 'Show Line Numbers';
uemShowUnitInfo = 'Unit Info';
lisDisableI18NForLFM = 'Disable I18N for LFM';
uemDebugWord = 'Debug';
uemToggleBreakpoint = '&Toggle Breakpoint';
uemEvaluateModify = '&Evaluate/Modify...';

View File

@ -3848,7 +3848,7 @@ begin
CurFilename:=AnUnitInfo.Filename;
if (not AnUnitInfo.IsVirtual) and FilenameIsPascalSource(CurFilename) then
begin
// check .lst file
// check .lrt file
LRTFilename:=ChangeFileExt(CurFilename,'.lrt');
if FileExistsCached(LRTFilename)
and ((not POFileAgeValid) or (FileAgeCached(LRTFilename)>POFileAge)) then
@ -5134,7 +5134,8 @@ begin
BinCompStream.Position:=0;
Writer:=CreateLRSWriter(BinCompStream,DestroyDriver);
// used to save lrt files
HasI18N:=AnUnitInfo.IsPartOfProject and AnUnitInfo.Project.EnableI18N;
HasI18N:=AnUnitInfo.IsPartOfProject and (not AnUnitInfo.DisableI18NForLFM)
and AnUnitInfo.Project.EnableI18N and AnUnitInfo.Project.EnableI18NForLFM;
if (not HasI18N) and (UnitOwners<>nil) then begin
for i:=0 to UnitOwners.Count-1 do begin
if TObject(UnitOwners[i]) is TLazPackage then begin

View File

@ -245,6 +245,7 @@ type
private
FCustomDefaultHighlighter: boolean;
FDefaultSyntaxHighlighter: TLazSyntaxHighlighter;
FDisableI18NForLFM: boolean;
FEditorInfoList: TUnitEditorInfoList;
FAutoReferenceSourceDir: boolean;
fAutoRevertLockCount: integer;// =0 means, codetools can auto update from disk
@ -310,6 +311,7 @@ type
procedure SetBuildFileIfActive(const AValue: boolean);
procedure SetDefaultSyntaxHighlighter(const AValue: TLazSyntaxHighlighter);
procedure SetDirectives(const AValue: TStrings);
procedure SetDisableI18NForLFM(const AValue: boolean);
procedure SetFileReadOnly(const AValue: Boolean);
procedure SetComponent(const AValue: TComponent);
procedure SetLoaded(const AValue: Boolean);
@ -432,6 +434,7 @@ type
property CustomDefaultHighlighter: boolean
read FCustomDefaultHighlighter write FCustomDefaultHighlighter;
property Directives: TStrings read FDirectives write SetDirectives;
property DisableI18NForLFM: boolean read FDisableI18NForLFM write SetDisableI18NForLFM;
property FileReadOnly: Boolean read fFileReadOnly write SetFileReadOnly;
property FirstRequiredComponent: TUnitComponentDependency
read FFirstRequiredComponent;
@ -672,6 +675,7 @@ type
FActiveWindowIndexAtStart: integer;
FEditorInfoList: TUnitEditorInfoList;
FAutoCreateForms: boolean;
FEnableI18NForLFM: boolean;
FTmpAutoCreatedForms: TStrings; // temporary, used to apply auto create forms changes
FAutoOpenDesignerFormsDisabled: boolean;
FBookmarks: TProjectBookmarkList;
@ -735,24 +739,25 @@ type
function JumpHistoryCheckPosition(
APosition:TProjectJumpHistoryPosition): boolean;
function OnUnitFileBackup(const Filename: string): TModalResult;
procedure ClearSourceDirectories;
procedure EmbeddedObjectModified(Sender: TObject);
procedure OnLoadSaveFilename(var AFilename: string; Load: boolean);
procedure OnUnitNameChange(AnUnitInfo: TUnitInfo;
const OldUnitName, NewUnitName: string;
CheckIfAllowed: boolean; var Allowed: boolean);
procedure SetAutoOpenDesignerFormsDisabled(const AValue: boolean);
procedure SetCompilerOptions(const AValue: TProjectCompilerOptions);
procedure SetEnableI18N(const AValue: boolean);
procedure SetEnableI18NForLFM(const AValue: boolean);
procedure SetMainProject(const AValue: boolean);
procedure SetMainUnitID(const AValue: Integer);
procedure SetPOOutputDirectory(const AValue: string);
procedure SetSkipCheckLCLInterfaces(const AValue: boolean);
procedure SetTargetFilename(const NewTargetFilename: string);
procedure SetEnableI18N(const AValue: boolean);
procedure SetPOOutputDirectory(const AValue: string);
procedure SetMainUnitID(const AValue: Integer);
procedure SourceDirectoriesChanged(Sender: TObject);
procedure UpdateProjectDirectory;
procedure UpdateSessionFilename;
procedure UpdateSourceDirectories;
procedure ClearSourceDirectories;
procedure SourceDirectoriesChanged(Sender: TObject);
procedure EmbeddedObjectModified(Sender: TObject);
protected
function GetMainFile: TLazProjectFile; override;
function GetMainFileID: Integer; override;
@ -952,6 +957,7 @@ type
property DefineTemplates: TProjectDefineTemplates read FDefineTemplates;
property Destroying: boolean read fDestroying;
property EnableI18N: boolean read FEnableI18N write SetEnableI18N;
property EnableI18NForLFM: boolean read FEnableI18NForLFM write SetEnableI18NForLFM;
property FirstAutoRevertLockedUnit: TUnitInfo read GetFirstAutoRevertLockedUnit;
property FirstLoadedUnit: TUnitInfo read GetFirstLoadedUnit;
property FirstPartOfProject: TUnitInfo read GetFirstPartOfProject;
@ -1514,6 +1520,7 @@ begin
fComponentResourceName := '';
FComponentState := wsNormal;
FDefaultSyntaxHighlighter := lshText;
FDisableI18NForLFM:=false;
FCustomDefaultHighlighter := False;
FEditorInfoList.ClearEachInfo;
fFilename := '';
@ -1589,6 +1596,8 @@ begin
if SaveSession and Assigned(Project.OnSaveUnitSessionInfo) then
Project.OnSaveUnitSessionInfo(Self);
if IsPartOfProject and SaveData then
XMLConfig.SetDeleteValue(Path+'DisableI18NForLFM/Value',FDisableI18NForLFM,false);
// context data (project/session)
if (IsPartOfProject and SaveData)
@ -1662,6 +1671,7 @@ begin
if fComponentName='' then
fComponentName:=XMLConfig.GetValue(Path+'FormName/Value','');
FComponentState := TWindowState(XMLConfig.GetValue(Path+'ComponentState/Value',0));
FDisableI18NForLFM:=XMLConfig.GetValue(Path+'DisableI18NForLFM/Value',false);
HasResources:=XMLConfig.GetValue(Path+'HasResources/Value',false);
FResourceBaseClass:=StrToComponentBaseClass(
XMLConfig.GetValue(Path+'ResourceBaseClass/Value',''));
@ -2313,6 +2323,13 @@ begin
FDirectives:=AValue;
end;
procedure TUnitInfo.SetDisableI18NForLFM(const AValue: boolean);
begin
if FDisableI18NForLFM=AValue then exit;
FDisableI18NForLFM:=AValue;
Modified:=true;
end;
procedure TUnitInfo.SetFileReadOnly(const AValue: Boolean);
begin
if fFileReadOnly=AValue then exit;
@ -2643,6 +2660,7 @@ begin
// i18n
xmlconfig.SetDeleteValue(Path+'i18n/EnableI18N/Value', EnableI18N, false);
xmlconfig.SetDeleteValue(Path+'i18n/EnableI18N/LFM', EnableI18NForLFM, true);
xmlconfig.SetDeleteValue(Path+'i18n/OutDir/Value',
SwitchPathDelims(CreateRelativePath(POOutputDirectory,ProjectDirectory),
fCurStorePathDelim) ,
@ -3102,6 +3120,7 @@ begin
EnableI18N := POOutputDirectory <> '';
end else begin
EnableI18N := xmlconfig.GetValue(Path+'i18n/EnableI18N/Value', False);
EnableI18NForLFM := xmlconfig.GetValue(Path+'i18n/EnableI18N/LFM', True);
POOutputDirectory := SwitchPathDelims(
xmlconfig.GetValue(Path+'i18n/OutDir/Value', ''),fPathDelimChanged);
end;
@ -3384,6 +3403,8 @@ begin
FActiveWindowIndexAtStart := -1;
FSkipCheckLCLInterfaces:=false;
FAutoOpenDesignerFormsDisabled := false;
FEnableI18N:=false;
FEnableI18NForLFM:=true;
FBookmarks.Clear;
FCompilerOptions.Clear;
FDefineTemplates.Clear;
@ -4811,6 +4832,13 @@ begin
inherited SetLazCompilerOptions(AValue);
end;
procedure TProject.SetEnableI18NForLFM(const AValue: boolean);
begin
if FEnableI18NForLFM=AValue then exit;
FEnableI18NForLFM:=AValue;
Modified:=true;
end;
procedure TProject.SetMainProject(const AValue: boolean);
begin
if MainProject=AValue then exit;

View File

@ -610,6 +610,7 @@ type
procedure ShowUnitInfo(Sender: TObject);
procedure SrcPopUpMenuPopup(Sender: TObject);
procedure ToggleLineNumbersClicked(Sender: TObject);
procedure ToggleI18NForLFMClicked(Sender: TObject);
procedure InsertCharacter(const C: TUTF8Char);
procedure SrcEditMenuCopyToNewWindowClicked(Sender: TObject);
procedure SrcEditMenuCopyToExistingWindowClicked(Sender: TObject);
@ -1181,6 +1182,7 @@ var
SrcEditMenuMoveEditorLast: TIDEMenuCommand;
SrcEditMenuReadOnly: TIDEMenuCommand;
SrcEditMenuShowLineNumbers: TIDEMenuCommand;
SrcEditMenuDisableI18NForLFM: TIDEMenuCommand;
SrcEditMenuShowUnitInfo: TIDEMenuCommand;
SrcEditMenuEditorProperties: TIDEMenuCommand;
{$IFnDEF SingleSrcWindow}
@ -1328,6 +1330,8 @@ begin
SrcEditMenuShowLineNumbers:=RegisterIDEMenuCommand(AParent,
'ShowLineNumbers',uemShowLineNumbers);
SrcEditMenuShowLineNumbers.ShowAlwaysCheckable:=true;
SrcEditMenuDisableI18NForLFM:=RegisterIDEMenuCommand(AParent,
'DisableI18NForLFM',lisDisableI18NForLFM);
SrcEditMenuShowUnitInfo:=RegisterIDEMenuCommand(AParent,'ShowUnitInfo',
uemShowUnitInfo);
SrcEditSubMenuHighlighter:=RegisterIDESubMenu(AParent,'Highlighter',
@ -5166,9 +5170,11 @@ begin
SrcEditMenuPaste.Enabled := not ASrcEdit.ReadOnly;
// Readonly, ShowLineNumbers
SrcEditMenuReadOnly.MenuItem.Checked:=ASrcEdit.ReadOnly;
SrcEditMenuShowLineNumbers.MenuItem.Checked :=
SrcEditMenuReadOnly.Checked:=ASrcEdit.ReadOnly;
SrcEditMenuShowLineNumbers.Checked :=
EditorComp.Gutter.LineNumberPart.Visible;
SrcEditMenuDisableI18NForLFM.Visible:=false;
UpdateHighlightMenuItems;
UpdateLineEndingMenuItems;
UpdateEncodingMenuItems;
@ -5405,6 +5411,7 @@ begin
SrcEditMenuReadOnly.OnClick:=@ReadOnlyClicked;
SrcEditMenuShowLineNumbers.OnClick:=@ToggleLineNumbersClicked;
SrcEditMenuDisableI18NForLFM.OnClick:=@ToggleI18NForLFMClicked;
SrcEditMenuShowUnitInfo.OnClick:=@ShowUnitInfo;
SrcEditMenuEditorProperties.OnClick:=@EditorPropertiesClicked;
@ -6352,6 +6359,11 @@ begin
EditorOpts.Save;
end;
procedure TSourceNotebook.ToggleI18NForLFMClicked(Sender: TObject);
begin
end;
Procedure TSourceNotebook.OpenAtCursorClicked(Sender: TObject);
begin
if assigned(Manager) and Assigned(Manager.OnOpenFileAtCursorClicked) then