Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
None
-
None
-
any
Description
When we use DatePicker in Chinese (TRADITIONAL_CHINESE or SIMPLIFIED_CHINESE), the method substring(String[] array, int len) cuts wrong word in WEEKDAYS_SHORT and WEEKDAYS_1CHAR.
It should be THIRD word in locale weekly message. So I write a subclass of DatePicker and fix it.
I think it is a major bug for Chinese though you guys had fixed it by ad-hoc re-assign a character array in simplified Chinese, but I think this should be correct solution listing below:
protected void localize(Map widgetProperties){
...
if (Locale.SIMPLIFIED_CHINESE.equals(getLocale()) || Locale.TRADITIONAL_CHINESE.equals(getLocale()))
widgetProperties.put("WEEKDAYS_SHORT", filterEmpty(substring(dfSymbols
.getShortWeekdays(), 2,1)));
...
}
/**
- An alternative solution for substring. It is equal to map(list, substring(start, length))
*/
protected final String[] substring(String[] array, int start,int len){
if (array != null)
{
String[] copy = new String[array.length];
for (int i = 0; i < array.length; i++)
{
String el = array[i];
if (el != null)Unknown macro: { if (el.length() > start) { copy[i] = el.substring(start, start+len); } else { copy[i] = el; } }}
return copy;
}
return null;
}