views:

930

answers:

3

Does anyone know how to localize the "Month", "Year", "Okay" and "Cancel" labels of the org.apache.wicket.extensions.yui.calendar.DatePicker?

According to the API you can override the the localize(Map) method to set up localized Strings, but i failed to find out what the names of the corresponding properties are.

A: 

The ticket 754 add support for localization.

May be the patch introduced then can give you some clues? It references:

src/main/java/org/apache/wicket/extensions/yui/calendar/locale/DatePicker_de.properties

with:

DATE_FIELD_DELIMITER=x
MDY_DAY_POSITION=1
MDY_MONTH_POSITION=2
MDY_YEAR_POSITION=3
MD_DAY_POSITION=1
MD_MONTH_POSITION=2

MONTHS_SHORT=Jan,Feb,M\u00E4r,Apr,Mai,Jun,Jul,Aug,Sep,Okt,Nov,Dez

MONTHS_LONG=Januar,Februar,M\u00E4rz,April,Mai,Juni,Juli,August,September,Oktober,November,Dezember
WEEKDAYS_1CHAR=S,M,D,M,D,F,S
WEEKDAYS_SHORT=So,Mo,Di,Mi,Do,Fr,Sa
WEEKDAYS_MEDIUM=Son,Mon,Die,Mit,Don,Fre,Sam
WEEKDAYS_LONG=Sonntag,Montag,Dienstag,Mittwoch,Donnerstag,Freitag,Samstag


Regarding the localization of the labels itself, may be you could try:

VonC
That allows for localization of the actual months and week days. What i'm looking for is localization for the labels "Month", "Year", "Okay" and "Cancel" (the latter 2 are button labels).
tehvan
@tehvan: "What I'm looking for is localization for the labels"... which you did already told me in your previous comment! Sorry about that. Still looking for the right answer.
VonC
A: 

I think you are talking about the labels on the calendar navigator. This example might be helpful.

hakan
+1  A: 

According to this you may localize the labels by overriding the configure method of the DatePicker class:

    public class DatePicker extends org.apache.wicket.extensions.yui.calendar.DatePicker {

    @Override
    protected void configure(Map<String, Object> widgetProperties) {
        super.configure(widgetProperties);

        /*
        * var navConfig = {
        *   strings: {
        *   month:"Calendar Month",
        *   year:"Calendar Year",
        *   submit: "Submit",
        *   cancel: "Cancel",
        *   invalidYear: "Please enter a valid year"
        *   },
        * monthFormat: YAHOO.widget.Calendar.SHORT,
        * initialFocus: "month"
        * }
        */

        Map<String, Object> strings = new HashMap<String, Object>();
        strings.put("month", "Месяц");
        strings.put("year", "Год");
        strings.put("submit", "Ok"); // put label for 'Okay' button
        strings.put("cancel", "Отмена"); // put label for 'Cancel' button
        strings.put("invalidYear", "Введите корректный год");

        Map<String, Object> props = new HashMap<String, Object>();
        props.put("strings", strings); // pass localization related parameters
        props.put("monthFormat", "YAHOO.widget.Calendar.SHORT");
        props.put("initialFocus", "year");

        widgetProperties.put("navigator", props);
    }
}

Hope you'll find this code snippet useful.