1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
|
unit project_i18n_options;
{$mode objfpc}{$H+}
interface
uses
Classes,
// LCL
StdCtrls, EditBtn, ExtCtrls, Graphics,
// LazUtils
LazFileUtils,
// IdeIntf
IDEOptionsIntf, IDEOptEditorIntf, IDEImagesIntf, IDEDialogs,
// IDE
Project, LazarusIDEStrConsts;
type
{ TProjectI18NOptionsFrame }
TProjectI18NOptionsFrame = class(TAbstractIDEOptionsEditor)
ForceUpdatePoFilesCheckBox: TCheckBox;
EnableI18NCheckBox: TCheckBox;
ExcludedGroupBox: TGroupBox;
I18NGroupBox: TGroupBox;
ExcludedIdentifiersMemo: TMemo;
ExcludedOriginalsMemo: TMemo;
ExcludedIdentifiersLabel: TLabel;
ExcludedIdentifiersPanel: TPanel;
ExcludedOriginalsPanel: TPanel;
ExcludedOriginalsLabel: TLabel;
PoForFormsCheckBox: TCheckBox;
POOutDirEdit: TEditButton;
PoOutDirLabel: TLabel;
procedure EnableI18NCheckBoxChange(Sender: TObject);
procedure ExcludedIdentifiersMemoChange(Sender: TObject);
procedure ExcludedOriginalsMemoChange(Sender: TObject);
procedure POOutDirButtonClick(Sender: TObject);
private
FProject: TProject;
FExcludedStringsChanged: Boolean;
procedure Enablei18nInfo(Usei18n: boolean);
public
function GetTitle: string; override;
procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
end;
implementation
{$R *.lfm}
{ TProjectI18NOptionsFrame }
procedure TProjectI18NOptionsFrame.EnableI18NCheckBoxChange(Sender: TObject);
begin
Enablei18nInfo(EnableI18NCheckBox.Checked);
end;
procedure TProjectI18NOptionsFrame.POOutDirButtonClick(Sender: TObject);
var
NewDirectory: string;
begin
NewDirectory := LazSelectDirectory(lisPOChoosePoFileDirectory,
FProject.Directory);
if NewDirectory = '' then Exit;
if not FProject.IsVirtual then
NewDirectory:=CreateRelativePath(NewDirectory,FProject.Directory);
POOutDirEdit.Text := NewDirectory;
end;
procedure TProjectI18NOptionsFrame.ExcludedIdentifiersMemoChange(Sender: TObject);
begin
FExcludedStringsChanged := True;
ExcludedIdentifiersLabel.Font.Style := [fsBold];
ForceUpdatePoFilesCheckBox.Font.Style := [fsBold];
end;
procedure TProjectI18NOptionsFrame.ExcludedOriginalsMemoChange(Sender: TObject);
begin
FExcludedStringsChanged := True;
ExcludedOriginalsLabel.Font.Style := [fsBold];
ForceUpdatePoFilesCheckBox.Font.Style := [fsBold];
end;
procedure TProjectI18NOptionsFrame.Enablei18nInfo(Usei18n: boolean);
begin
I18NGroupBox.Enabled := Usei18n;
ExcludedGroupBox.Enabled := Usei18n;
ForceUpdatePoFilesCheckBox.Enabled := Usei18n;
end;
function TProjectI18NOptionsFrame.GetTitle: string;
begin
Result := dlgPOI18n;
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;
ExcludedGroupBox.Caption := rsI18nExcluded;
ExcludedIdentifiersLabel.Caption := rsI18nIdentifiers;
ExcludedOriginalsLabel.Caption := rsI18nOriginals;
ForceUpdatePoFilesCheckBox.Caption := rsI18nForceUpdatePoFilesOnNextBuild;
end;
procedure TProjectI18NOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions);
begin
FProject := (AOptions as TProjectIDEOptions).Project;
with FProject do
begin
POOutDirEdit.Text := POOutputDirectory;
EnableI18NCheckBox.Checked := Enablei18n;
PoForFormsCheckBox.Checked:=EnableI18NForLFM;
ExcludedIdentifiersMemo.Lines.Clear;
ExcludedIdentifiersMemo.Lines.AddStrings(I18NExcludedIdentifiers);
ExcludedOriginalsMemo.Lines.Clear;
ExcludedOriginalsMemo.Lines.AddStrings(I18NExcludedOriginals);
ForceUpdatePoFilesCheckBox.Checked := ForceUpdatePoFiles;
Enablei18nInfo(Enablei18n);
end;
FExcludedStringsChanged := False;
ExcludedIdentifiersLabel.ParentFont := True;
ExcludedOriginalsLabel.ParentFont := True;
ForceUpdatePoFilesCheckBox.ParentFont := True;
IDEImages.AssignImage(POOutDirEdit.Button, ResBtnSelDir); //DirectoryEdit
end;
procedure TProjectI18NOptionsFrame.WriteSettings(AOptions: TAbstractIDEOptions);
begin
with (AOptions as TProjectIDEOptions).Project do
begin
POOutputDirectory := POOutDirEdit.Text;
EnableI18N := EnableI18NCheckBox.Checked;
EnableI18NForLFM := PoForFormsCheckBox.Checked;
I18NExcludedIdentifiers.Clear;
I18NExcludedIdentifiers.AddStrings(ExcludedIdentifiersMemo.Lines);
I18NExcludedOriginals.Clear;
I18NExcludedOriginals.AddStrings(ExcludedOriginalsMemo.Lines);
ForceUpdatePoFiles := ForceUpdatePoFilesCheckBox.Checked;
if FExcludedStringsChanged then
Modified := True;
end;
end;
class function TProjectI18NOptionsFrame.SupportedOptionsClass: TAbstractIDEOptionsClass;
begin
Result := TProjectIDEOptions;
end;
initialization
RegisterIDEOptionsEditor(GroupProject, TProjectI18NOptionsFrame, ProjectOptionsI18N);
end.
|