gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 08:59:09 25 4
gpt4 key购买 nike

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

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

最佳答案

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

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

关于java - 本地化 org.apache.wicket.extensions.yui.calendar.DatePicker 中的标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1304168/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com