本地化 org.apache.wicket.extensions.yui.calendar.DatePicker 中的标签

发布于 2024-08-02 23:31:35 字数 154 浏览 2 评论 0 原文

有谁知道如何本地化 org.apache.wicket.extensions.yui.calendar.DatePicker 的“月”、“年”、“好”和“取消”标签?

根据API,您可以重写 localize(Map) 方法来设置本地化字符串,但我无法找出相应属性的名称是什么。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

╄→承喏 2024-08-09 23:31:35

根据 this 您可以通过覆盖以下配置方法来本地化标签DatePicker 类:

    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);
    }
}

希望您会发现此代码片段有用。

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.

方觉久 2024-08-09 23:31:35

ticket 754 添加了对 本地化

可能是引入的补丁可以给你一些线索?它引用:

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

关于标签本身的本地化,也许你可以尝试:

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:

内心荒芜 2024-08-09 23:31:35

我认为您正在谈论日历导航器上的标签。这个示例可能会有所帮助。

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

森林散布 2024-08-09 23:31:35

我认为这个解决方案很好:

protected static final String[] NAVIGATOR_LOCALIZATION_KEYS = {
    "month", "year", "submit", "cancel", "invalidYear",
};

In overridden method u should write: 

super.configure(widgetProperties, response, initVariables);
    Map<String, String> strings = MapBuilder.newHashMap();
    for (String key : NAVIGATOR_LOCALIZATION_KEYS) {
        strings.put(key, LocalizationUtils.getString(key));
    }
    widgetProperties.put(
        "navigator", Collections.singletonMap("strings", strings)
    );

I think this solution is nice:

protected static final String[] NAVIGATOR_LOCALIZATION_KEYS = {
    "month", "year", "submit", "cancel", "invalidYear",
};

In overridden method u should write: 

super.configure(widgetProperties, response, initVariables);
    Map<String, String> strings = MapBuilder.newHashMap();
    for (String key : NAVIGATOR_LOCALIZATION_KEYS) {
        strings.put(key, LocalizationUtils.getString(key));
    }
    widgetProperties.put(
        "navigator", Collections.singletonMap("strings", strings)
    );
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文