日本語表示にする

書式

calendarObj.cfg.setProperty("MONTHS_SHORT", monthString)
calendarObj.cfg.setProperty("MONTHS_LONG", monthString)
calendarObj.cfg.setProperty("WEEKDAYS_1CHAR", DayString)
calendarObj.cfg.setProperty("WEEKDAYS_SHORT", DayString)
calendarObj.cfg.setProperty("WEEKDAYS_MEDIUM", DayString)
calendarObj.cfg.setProperty("WEEKDAYS_LONG", DayString)
calendarObj : カレンダーオブジェクト
monthString : 月を示す文字列を格納した配列
DayString : 曜日を示す文字列を格納した配列

説明

 日本語表示にするにはカレンダーオブジェクトのcfg内の各プロパティに曜日を配列形式で指定します。Config.Locale.WEEKDAYS_1CHARであれば1文字の曜日を示すので["日","月","火","水","木","金","土"]と指定すると曜日が日本語化されます。試したところでは配列形式でなくても"日月火水木金土"の文字列でも表示できるようです。

サンプルコード [実行]

<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>Sample</title>
<link rel="stylesheet" href="main.css" type="text/css" media="all">
<link rel="stylesheet" href="css/calendar.css" type="text/css" media="all">
<script type="text/javascript" src="yui/yahoo.js"></script>
<script type="text/javascript" src="yui/dom.js"></script>
<script type="text/javascript" src="yui/event.js"></script>
<script type="text/javascript" src="yui/calendar.js"></script>
<script type="text/javascript"><!--
window.onload = function(){
var myCalendar = new YAHOO.widget.Calendar("cal", "myCalendar");
myCalendar.customConfig = function(){
var jpDayStr = ["日","月","火","水","木","金","土"];
var jpMonth = ["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"];
this.Config.Locale.MONTHS_SHORT = jpMonth;
this.Config.Locale.MONTHS_LONG = jpMonth;
this.Config.Locale.WEEKDAYS_1CHAR = jpDayStr;
this.Config.Locale.WEEKDAYS_SHORT = jpDayStr;
this.Config.Locale.WEEKDAYS_MEDIUM = jpDayStr;
this.Config.Locale.WEEKDAYS_LONG = jpDayStr;
}
myCalendar.setupConfig();
myCalendar.render();
}
// --></script>
</head>
<body>
<h1>日本語表示にする</h1>
<div id="myCalendar"></div>
</body>
</html>