classIndonesianDialog


Atas permintaan Mas Rahman, untuk memunculkan dialog di Delphi berbahasa Indonesia, maka saya posting library berikut. Library ini berguna untuk mengubah tombol konfirmasi dari bahasa Inggris menjadi bahasa Indonesia. Sebenarnya cuma menggunakan semacam facade pattern dari fungsi CreateMessageDialog(Msg, DlgType, Buttons).

function CreateMessageDialog(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons): TForm;

Description

Call CreateMessageDialog to create a message dialog that will be used several times in an application. CreateMessageDialog returns a dialog of the type specified by the DlgType parameter and with the buttons indicated by the Buttons parameter. Users can copy messages created using CreateMessageDialog to the clipboard by pressing Ctrl+C.

Note: CreateMessageDialog does not display the dialog form. The application must display this form when it is needed by calling its ShowModal method.

Semoga berguna Mas:

unit classIndonesianDialog;

interface

uses
    Dialogs, Forms, StdCtrls, SysUtils;

type
    TIndonesianDialog = class(TObject)
    public
      class function MessageDlg(const Msg: string; DlgType: TMsgDlgType;
      Buttons: TMsgDlgButtons): Word;
      class function ShowError(Msg:String):Word;
end;

implementation

{ TIndonesianDialog }

class function TIndonesianDialog.MessageDlg(const Msg: string;
  DlgType: TMsgDlgType; Buttons: TMsgDlgButtons): Word;
var
   aForm:TForm;
   i:integer;
   captionButton:String;
begin
     aForm := CreateMessageDialog(Msg, DlgType, Buttons);
     for i := 0 to aForm.ComponentCount - 1 do
     begin
          captionButton := '';
          if (aForm.Components[i] is TButton) then
          begin
               captionButton := (aForm.Components[i] as TButton).Caption;
               if (captionButton = '&Yes') or
                  (captionButton = 'Yes') then
                  captionButton  := 'Ya'
               else if (captionButton = '&Cancel') or
                       (captionButton = 'Cancel') then
                       captionButton := 'Batal'
               else if (captionButton = '&No') or
                       (captionButton = 'No') then
                       captionButton := 'Tidak'
               else if (captionButton = '&Help') or
                       (captionButton = 'Help') then
                       captionButton := 'Panduan'
               else if (captionButton = '&Ignore') or
                       (captionButton = 'Ignore') then
                       captionButton := 'Abaikan'
               else if (captionButton = '&No') or
                       (captionButton = 'No') then
                       captionButton := 'Tidak'
               else if (captionButton = '&Retry') or
                       (captionButton = 'Retry') then
                       captionButton := 'Coba lagi'
               else if (UpperCase(captionButton) = '&NO TO ALL') or
                       (UpperCase(captionButton) = 'NO TO ALL') then
                       captionButton := 'Tidak untuk semua'
               else if (UpperCase(captionButton) = '&YES TO ALL') or
                       (UpperCase(captionButton) = 'YES TO ALL') then
                       captionButton := 'Ya untuk semua'
               else if (UpperCase(captionButton) = '&ALL') or
                       (UpperCase(captionButton) = 'ALL') then
                       captionButton := 'Semua';
          end;
          if captionButton <> '' then
             (aForm.Components[i] as TButton).Caption := captionButton;
     end;
     
     if aForm.Caption = 'Confirm' then
        aForm.Caption := 'Konfirmasi'
     else if aForm.Caption = 'Error' then
        aForm.Caption := 'Kesalahan'
     else if aForm.Caption = 'Information' then
        aForm.Caption := 'Informasi'
     else if aForm.Caption = 'Warning' then
        aForm.Caption := 'Peringatan';

     Result := aForm.showModal;
end;

class function TIndonesianDialog.ShowError(Msg: String): Word;
begin
     Result := Self.MessageDlg(Msg, mtError, [mbOk]);
end;

end.

 

Iklan

Posted on Juni 9, 2007, in Pemrograman, Ulasan and tagged , . Bookmark the permalink. Tinggalkan komentar.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: