クラウディなネットワーク上システム開発に「CodeGear」の「Delphi for PHP」を使用しています。ところが、付属しているVCLカレンダーは日本語化モジュールは存在しますが、何故か未完成で使用不可となっています。これを自分なりに日本語化し使用しています。そこで今回情報シェア―の為、投稿します。ちょっと長文になりますが、お役に立てればと思います。ターゲット: (CodeGear) Delphi for PHP 2.1.0.1098 / DateTimePicker及びMonthCalendar まずは、「Delphi4phpインストールパス\vcl\jscalendar\lang\calendar-jp.js」をオープンします。(もし、存在しなければテキストエディターで作成して下さい。) 以下のコードをペーストして保存して下さい
----ここから
// ** I18N
Calendar._DN = new Array ("日曜日", "月曜日", "火曜日", "水曜日", "木曜日", "金曜日", "土曜日", "日曜日");
Calendar._SDN = new Array ("日", "月", "火", "水", "木", "金", "土", "日");
// その週の初日設定 "0" 日曜日, "1" 月曜日
Calendar._FD = 0;
Calendar._MN = new Array ("1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月");
Calendar._SMN = new Array ("1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月");
// tooltips
Calendar._TT = {};
Calendar._TT["INFO"] = "カレンダー情報...";
Calendar._TT["ABOUT"] = "DHTML Date/Time Selector\n" + "(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + // don't translate this this ;-)
"For latest version visit: http://www.dynarch.com/projects/calendar/" + "GNU LGPLによる配布。詳細は http://gnu.org/licenses/lgpl.html まで..." + "\n\n" + "日付選択方法:\n" + "- \xab, \xbb 年選択ボタンです...\n" + "- " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " 月選択ボタンです...\n" + "- マウスボタンをホールドすると高速に選択できます...";
Calendar._TT["ABOUT_TIME"] = "\n\n" + "時刻選択方法:\n" + "- 各部分をクリックして時刻を前進させるか、\n" + "- シフトキーを押しながらクリックして時刻を後退させるか\n" + "- 又は、クリックしながらドラッグすれば高速で時刻変更ができます...";
Calendar._TT["TOGGLE"] = "週の最初の曜日を切り替え";
Calendar._TT["PREV_YEAR"] = "前年";
Calendar._TT["PREV_MONTH"] = "前月";
Calendar._TT["GO_TODAY"] = "今日";
Calendar._TT["NEXT_MONTH"] = "翌月";
Calendar._TT["NEXT_YEAR"] = "翌年";
Calendar._TT["SEL_DATE"] = "日付選択";
Calendar._TT["DRAG_TO_MOVE"] = "ウィンドウの移動";
Calendar._TT["PART_TODAY"] = " (今日)";
//Calendar._TT["PART_TODAY"] = " (today)";
Calendar._TT["MON_FIRST"] = "月曜日を先頭に";
Calendar._TT["SUN_FIRST"] = "日曜日を先頭に";
Calendar._TT["CLOSE"] = "閉じる";
Calendar._TT["TODAY"] = "今日";
Calendar._TT["TIME_PART"] = "(Shift-)クリックかドラッグで変更...";
Calendar._TT["DAY_FIRST"] = "%sを週の初日に設定します...";
Calendar._TT["WK"] = "週"; Calendar._TT["TIME"] = "時間:";
// This may be locale-dependent. It specifies the week-end days, as an array
// of comma-separated numbers. The numbers are from 0 to 6: 0 means Sunday, 1
// means Monday, etc.
Calendar._TT["WEEKEND"] = "0,6";
// date formats
//Calendar._TT["DEF_DATE_FORMAT"] = "%Y-%m-%d";
//Calendar._TT["TT_DATE_FORMAT"] = "%a, %b %e";
Calendar._TT["DEF_DATE_FORMAT"] = "y-mm-dd";
Calendar._TT["TT_DATE_FORMAT"] = "%m月 %d日 (%a)";
----ここまで 次のページに続く・・・
次に、VCL化します。「DateTimePickerEx.inc.php」という名前のファイルをテキストエディターで作成し以下のコードをペーストします。
----ここから
<?php
require_once("vcl/vcl.inc.php");
//Includes
use_unit("comctrls.inc.php");
//Class definition
class DateTimePickerEx extends DateTimePicker {
function __construct($aowner = null){ parent::__construct($aowner); }
function dumpContents(){
$style=$this->Font->FontString;
if ($this->color!=""){ $style.="background-color: ".$this->color.";"; }
$h=$this->Height-1;
$w=$this->Width;
$d=15;
if ($h!=15) $d=$h;
$style.="height:".$h."px;width:".($w-$d)."px;";
date_default_timezone_set($this->TimeZone);
if ($this->TimeFormat=='24時間制') { $TimeFormat='24'; }
else { $TimeFormat='12'; }
if ($this->Firstday=='月曜日') { $Firstday=1; }
elseif ($this->Firstday=='火曜日') { $Firstday=2; }
elseif ($this->Firstday=='水曜日') { $Firstday=3; }
elseif ($this->Firstday=='木曜日') { $Firstday=4; }
elseif ($this->Firstday=='金曜日') { $Firstday=5; }
elseif ($this->Firstday=='土曜日') { $Firstday=6; }
else { $Firstday=0; }
$this->_calendar->make_input_field ( array('firstDay' => $Firstday, 'showsTime' => $this->_showsTime, 'showOthers' => $this->_ShowOthers, 'ifFormat' => $this->_ifFormat, 'timeFormat' => $TimeFormat), array('style' => $style, 'name' => $this->Name, 'value' => $this->_text), $h );
}
protected $_Lang = 'jp';
function getLang() { return $this->_Lang; }
function setLang($value) {
$this->_Lang=$value;
$this->_calendar->DHTML_Calendar(VCL_HTTP_PATH."/jscalendar/", $value , $this->Profile, false);
}
function defaultLang() { return 'jp'; }
protected $_Profile='calendar-win2k-2';
function getProfile() { return $this->_Profile; }
function setProfile($value) {
$this->_Profile=$value;
$this->_calendar->DHTML_Calendar(VCL_HTTP_PATH."/jscalendar/", $this->Lang, $value, false);
}
function defaultProfile() { return ''; }
protected $_TimeFormat='24時間制';
function getTimeFormat() { return $this->_TimeFormat; }
function setTimeFormat($value) { $this->_TimeFormat=$value; }
function defaultTimeFormat() { return '24時間制'; }
protected $_Firstday='月曜日'; //1=>月曜日, 0=>日曜日
function getFirstday() { return $this->_Firstday; }
function setFirstday($value) { $this->_Firstday=$value; }
function defaultFirstday() { return '月曜日'; }
protected $_ShowOthers=true;
function getShowOthers() { return $this->_ShowOthers; }
function setShowOthers($value) { $this->_ShowOthers=$value; }
function defaultShowOthers() { return true; }
protected $_ifFormat='%Y/%m/%d %H:%M:%S %P';
function getIfFormat() { return $this->_ifFormat; }
function setIfFormat($value) { $this->_ifFormat=$value; }
function defaultIfFormat() { return '%Y/%m/%d %H:%M:%S %P'; }
private $_timezone='Japan';
function getTimeZone() { return $this->_timezone; }
function setTimeZone($value) {
$this->_timezone=$value;
date_default_timezone_set($value);
}
function defaultTimeZone() { return ''; }
}
?>
----ここまで
「MonthCalendarEx.inc.php」という名前のファイルをテキストエディターで作成し以下のコードをペーストします。
----ここから
<?php
require_once("vcl/vcl.inc.php");
//Includes
use_unit("comctrls.inc.php");
//Class definition
class MonthCalendarEx extends MonthCalendar {
function __construct($aowner = null) { parent::__construct($aowner); }
function dumpContents() {
//parent::dumpContents();
echo "<input type=\"hidden\" name=\"{$this->Name}_date\" id=\"{$this->Name}_date\" value=\"$this->_date\" />\n";
$date=$this->Date;
if ($date=='') { $date=date('m/d/Y H:i:s');
//$date=date('Y/m/d h:i:s A');
}
$onupdate="null";
if (($this->ControlState & csDesigning)!=csDesigning) {
//if ($this->_jsonupdate!=null) $onupdate=$this->_jsonupdate;
$onupdate=$this->Name.'_update';
}
if ($this->TimeFormat=='24時間制') { $TimeFormat='24'; }
else { $TimeFormat='12'; }
if ($this->Firstday=='月曜日') { $Firstday=1; }
elseif ($this->Firstday=='火曜日') { $Firstday=2; }
elseif ($this->Firstday=='水曜日') { $Firstday=3; }
elseif ($this->Firstday=='木曜日') { $Firstday=4; }
elseif ($this->Firstday=='金曜日') { $Firstday=5; }
elseif ($this->Firstday=='土曜日') { $Firstday=6; }
else { $Firstday=0; }
echo "<div id=\"".$this->Name."_container\">\n";
echo $this->_calendar->_make_calendar( array( 'flat'=>$this->Name."_container", 'firstDay' => $Firstday, 'showsTime' => $this->_showsTime, 'width' => $this->Width, 'height' => $this->Height, 'date' => $date, 'onUpdate' => $onupdate, 'showOthers'=> $this->_ShowOthers, 'ifFormat' => $this->_ifFormat, 'daFormat' => $this->_dateformat, 'timeFormat'=> $TimeFormat ), $this->Name) . "\n"; echo "</div>\n"; echo "<script type=\"text/javascript\">\n"; echo "$this->Name.table.width='".($this->Width-3)."px';\n"; echo " $this->Name.table.height='".($this->Height-3)."px';\n"; echo "</script>";
}
protected $_Lang = 'jp';
function getLang() { return $this->_Lang; }
function setLang($value) {
$this->_Lang=$value;
$this->_calendar->DHTML_Calendar(VCL_HTTP_PATH."/jscalendar/", $value , $this->Profile, false);
}
function defaultLang() { return 'jp'; }
protected $_Profile='calendar-win2k-2';
function getProfile() { return $this->_Profile; }
function setProfile($value) {
$this->_Profile=$value;
$this->_calendar->DHTML_Calendar(VCL_HTTP_PATH."/jscalendar/", $this->Lang, $value, false);
}
function defaultProfile() { return ''; }
protected $_TimeFormat='24時間制';
function getTimeFormat() { return $this->_TimeFormat; }
function setTimeFormat($value) { $this->_TimeFormat=$value; }
function defaultTimeFormat() { return '24時間制'; }
protected $_Firstday='月曜日'; //1=>月曜日, 0=>日曜日
function getFirstday() { return $this->_Firstday; }
function setFirstday($value) { $this->_Firstday=$value; }
function defaultFirstday() { return '月曜日'; }
protected $_ShowOthers=true;
function getShowOthers() { return $this->_ShowOthers; }
function setShowOthers($value) { $this->_ShowOthers=$value; }
function defaultShowOthers() { return true; }
protected $_ifFormat='%Y/%m/%d %H:%M:%S %P';
function getIfFormat() { return $this->_ifFormat; }
function setIfFormat($value) { $this->_ifFormat=$value; }
function defaultIfFormat() { return '%Y/%m/%d %H:%M:%S %P'; }
protected $_showsTime=true;
function getShowsTime() { return $this->_showsTime; }
function setShowsTime($value) { $this->_showsTime=$value; }
function defaultShowsTime() { return true; }
protected $_dateformat='%Y/%m/%d %H:%M:%S %P';
function getDateFormat() { return $this->_dateformat; }
function setDateFormat($value) { $this->_dateformat=$value; }
function defaultDateFormat() { return '%Y/%m/%d %H:%M:%S %P'; }
private $_timezone='Japan';
function getTimeZone() { return $this->_timezone; }
function setTimeZone($value) {
$this->_timezone=$value;
date_default_timezone_set($value);
}
function defaultTimeZone() { return ''; }
}
?>
----ここまで
上記で作成した「DateTimePickerEx.inc.php」「MonthCalendarEx.inc.php」を任意の場所に保存します。さあ、もうすこしです・・・がんばりましょう。後は、パッケージ登録処理だけで完了です。「Delphi4phpインストールパス\vcl\packages」内にテキストエディターで「JpnComp.package.php」というファイルを作成します。(任意の名前で構いません) そして、下記のコードをペーストし保存して下さい。
----ここから
<?php
require_once("vcl/vcl.inc.php");
use_unit("designide.inc.php");
setPackageTitle("サミーのコンポ集"); //任意の名前でかまいません。//Change this setting to the path where the icons for the components reside
setIconPath("./icons");
//Change yourunit.inc.php to the php file which contains the component code
registerComponents("Sammy's components",array("MonthCalendarEx"),"SammyComp/MonthCalendarEx.inc.php");
//"Sammy's components"は任意の名前でOKです。"SammyComp/MonthCalendarEx.inc.php"は、先ほど保存した任意の場所へのパスですので、必要あればパス修正して下さい。次の行も同様です。
registerComponents("Sammy's components",array("DateTimePickerEx"),"SammyComp/DateTimePickerEx.inc.php");
registerPropertyValues("MonthCalendarEx","Lang",array('jp','en','ro'));
registerPropertyValues("MonthCalendarEx","Profile",array('calendar-tas','calendar-system','calendar-brown','calendar-green','calendar-blue1','calendar-blue2','calendar-win2k-cold-1','calendar-win2k-cold-2','calendar-win2k-1','calendar-win2k-2','calendar-win2k-3'));
registerPropertyValues("MonthCalendarEx","TimeFormat",array('24時間制','12時間制')); registerBooleanProperty("MonthCalendarEx","ShowOthers");
registerPropertyValues("MonthCalendarEx","Firstday",array('日曜日','月曜日','火曜日','水曜日','木曜日','金曜日','土曜日'));
registerBooleanProperty("MonthCalendarEx","ShowsTime");
registerPropertyValues("DateTimePickerEx","Lang",array('jp','en','ro'));
registerPropertyValues("DateTimePickerEx","Profile",array('calendar-tas','calendar-system','calendar-brown','calendar-green','calendar-blue1','calendar-blue2','calendar-win2k-cold-1','calendar-win2k-cold-2','calendar-win2k-1','calendar-win2k-2','calendar-win2k-3'));
registerPropertyValues("DateTimePickerEx","TimeFormat",array('24時間制','12時間制'));
registerBooleanProperty("DateTimePickerEx","ShowOthers"); registerPropertyValues("DateTimePickerEx","Firstday",array('日曜日','月曜日','火曜日','水曜日','木曜日','金曜日','土曜日'));
?>
----ここまで
以上です。後は、コンポネント登録すれば完了です。長文でしたが、必要な方は試してみてください。但し、自分の環境では問題なく稼働していますが、ご使用はご自分の責任でお願いしますね。![]()
