# YUI Calendar: Localization: Japan

# Setting up the Calendar

Calendar provides easy configuration properties that can be used to localize the Calendar's various data labels to be used in international locales. There are several properties that are used to change localization settings:

- LOCALE_MONTHS - The setting that determines which length of month labels should be used. Possible values are "short" and "long".
- LOCALE_WEEKDAYS - The setting that determines which length of weekday labels should be used. Possible values are "1char", "short", "medium", and "long".
- MONTHS_SHORT - The short month labels for the current locale. Default: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
- MONTHS_LONG - The long month labels for the current locale. Default: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
- WEEKDAYS_1CHAR - The 1-character weekday labels for the current locale. Default: ["S", "M", "T", "W", "T", "F", "S"]
- WEEKDAYS_SHORT - The short weekday labels for the current locale. Default: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]
- WEEKDAYS_MEDIUM - The medium weekday labels for the current locale. Default: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
- WEEKDAYS_LONG - The long weekday labels for the current locale. Default: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]

In addition, the Calendar provides special configuration properties for determining how incoming dates and date ranges should be formatted. By default, the date format for input to the Calendar is mm/dd/yyyy. Ranges are separated by a dash ("-") and lists of dates are delimited using a comma (","). Using these properties, the initial formatting of date can be easily modified:

- DATE_DELIMITER - The value used to delimit individual dates in a date string passed to various Calendar functions. Default: ","
- DATE_FIELD_DELIMITER - The value used to delimit date fields in a date string passed to various Calendar functions. Default: "/"
- DATE_RANGE_DELIMITER - The value used to delimit date ranges in a date string passed to various Calendar functions. Default: "-"
- MDY_MONTH_POSITION - The position of the month in a month/day/year date string. Default: 1
- MDY_DAY_POSITION - The position of the day in a month/day/year date string. Default: 2
- MDY_YEAR_POSITION - The position of the year in a month/day/year date string. Default: 3
- MD_MONTH_POSITION - The position of the month in a month/day date string. Default: 1
- MD_DAY_POSITION - The position of the day in a month/day date string. Default: 2
- MY_MONTH_POSITION - The position of the month in a month/year date string. Default: 1
- MY_YEAR_POSITION - The position of the year in a month/year date string. Default: 2

In our tutorial, we will create a Japanese Calendar that is set up both to accept dates in the standard Japanese format (yyyy/mm/dd) and present the labels in Japanese. Note that all of our date label values will contain special characters in Unicode notation.

YAHOO.example.calendar.cal1 = new YAHOO.widget.CalendarGroup("cal1","cal1Container", { START_WEEKDAY: 1, MULTI_SELECT:true } ); // Correct formats for Japan: yyyy/mm/dd, mm/dd, yyyy/mm YAHOO.example.calendar.cal1.cfg.setProperty("MDY_YEAR_POSITION", 1); YAHOO.example.calendar.cal1.cfg.setProperty("MDY_MONTH_POSITION", 2); YAHOO.example.calendar.cal1.cfg.setProperty("MDY_DAY_POSITION", 3); YAHOO.example.calendar.cal1.cfg.setProperty("MY_YEAR_POSITION", 1); YAHOO.example.calendar.cal1.cfg.setProperty("MY_MONTH_POSITION", 2); // Date labels for Japanese locale YAHOO.example.calendar.cal1.cfg.setProperty("MONTHS_SHORT", ["1\u6708", "2\u6708", "3\u6708", "4\u6708", "5\u6708", "6\u6708", "7\u6708", "8\u6708", "9\u6708", "10\u6708", "11\u6708", "12\u6708"]); YAHOO.example.calendar.cal1.cfg.setProperty("MONTHS_LONG", ["1\u6708", "2\u6708", "3\u6708", "4\u6708", "5\u6708", "6\u6708", "7\u6708", "8\u6708", "9\u6708", "10\u6708", "11\u6708", "12\u6708"]); YAHOO.example.calendar.cal1.cfg.setProperty("WEEKDAYS_1CHAR", ["\u65E5", "\u6708", "\u706B", "\u6C34", "\u6728", "\u91D1", "\u571F"]); YAHOO.example.calendar.cal1.cfg.setProperty("WEEKDAYS_SHORT", ["\u65E5", "\u6708", "\u706B", "\u6C34", "\u6728", "\u91D1", "\u571F"]); YAHOO.example.calendar.cal1.cfg.setProperty("WEEKDAYS_MEDIUM",["\u65E5", "\u6708", "\u706B", "\u6C34", "\u6728", "\u91D1", "\u571F"]); YAHOO.example.calendar.cal1.cfg.setProperty("WEEKDAYS_LONG", ["\u65E5", "\u6708", "\u706B", "\u6C34", "\u6728", "\u91D1", "\u571F"]);

Next, we can set some selected dates using our newly configured date format, and render the Calendar:

YAHOO.example.calendar.cal1.select("2006/10/1-2006/10/8"); YAHOO.example.calendar.cal1.render();
Continue to Functional Example >