Visit our Sponsor   Visit our Sponsor
delphi3000.com - the free delphi knowledge platform
delphi3000.com - the free delphi knowledge platform
Have a look at your member-status

connecting people's knowledge


  - Recent ArticlesRSS feed for Recent Articles on delphi3000.com
  - List of All Articles
  - Top Viewed Articles
  - Articles (+Attachem.)
  - Articles Of Interest
  - Categories
  - Top Uploader
  - Search
  - Index

  - My Home
  - Submit an Article
  - My Articles
  - My Personal Data
  - My Bookmarks
  - Activities
  - Login/Logout

  - Sign Up
  - Why Sign Up
  - Newsletter

  - Press
  - Advertise

  - Contact
  - Feedback





Community
Borland
ClubeDelphi
Dr. Bob
UK-BUG
Delphi Meetings
Planeta Delphi







Startblatt.de






Share this article with friendsShare this article with friends
Rate this articleRate this article - to keep the quality of delphi3000.com !
Comment this article or read through previous comments (0)


Displaying Month Names in Indonesian or Other Language Using FormatDateTime FunctionFormat this article printer-friendly!Bookmark function is only available for registered users!
Replace Default LongMonthNames Constant
Product:
Delphi all versions
Category:
System
Skill Level:
Scoring:
Last Update:
01/21/2007
Search Keys:
delphi delphi3000 article borland vcl code-snippet Indonesian-Month-Names FormatDateTime LongMonthNames
Times Scored:
6
Visits:
2267
Uploader: Hary Purnomo
Company:
Reference: http://delphimiracles.blogspot.com/
 
Question/Problem/Abstract:
» How we can display long month names in a specific language, eg Indonesia
So, the result will be like this : today is 25 Nopember 2006
Answer:



Actually, that's quiet simple to do that
You only need to replace the default (Delphi) "LongMonthNames" constants with the preferable any language you desire.

For this example, I want to display a specific date into Indonesian Date Format (dd MMMM yyyy)

Which,
   » January is Januari in Indonesian
   » February is Februari
   » March is Maret
   » April is April
   » May is Mei
   » June is Juni
   » July is Juli
   » August is Agustus
   » September is September (unchanged)
   » October is Oktober
   » November is Nopember
   » December is Desember

The example code would be like this :
-------------------------------------
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    DateTimePicker1: TDateTimePicker;
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

  // English:
  //   this variable ("namaBulan") is used to replace month names' string
  //   from English into Indonesian
  // this variable is used in "replaceLongMonthNamesWithIndonesian" procedure

  // dipakai untuk menggantikan string nama bulan dr bhs Inggris ke Indonesia
  // digunakan dalam procedure "replaceLongMonthNamesWithIndonesian"
  namaBulan: array[1..12] of string =
    ( 'Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni', 'Juli',
      'Agustus', 'September', 'Oktober', 'Nopember', 'Desember');

  // You can change the string constant above with your language choice

implementation

{$R *.dfm}

procedure replaceLongMonthNamesWithIndonesian;
var i : integer;
begin
  for i:=1 to High(namaBulan) do
    LongMonthNames[i] := namaBulan[i];
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  replaceLongMonthNamesWithIndonesian;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowMessageFmt(
    'The date in Indonesian format (dd mmmm yyyy) : %s',
    [FormatDateTime('dd MMMM yyyy', DateTimePicker1.Date)]);
end;

end.

-------------------------------------
// end of the code

if you want to change the short name of a month with some other language either, you need to change the "ShortMonthNames" like we did above


Enjoy it





Please rate this article!
Skill level:
BeginnerExpert

Useful:
No!Very!

Overall rating:
PoorExcellent



Comments to this article
Write a new comment













 
Sign up to consume product discounts for Bronze memberships !

read more


  Visit our Sponsor

 

  Community Ad of
S. Carter
 
   














 







     
  Copyright © 2000 - 2007 delphi3000.com - All rights reserved. Terms of use. || Privacy
delphi3000.com is a service by bluestep.com IT-Services GmbH (Vienna)