Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-2218

DatePicker pick up wrong word when we use LOCALE_WEEKDAYS with 1char in chinese.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 1.4-RC3
    • wicket-datetime
    • 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;
        }

      Attachments

        Activity

          People

            Unassigned Unassigned
            neversay Neversay
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 0.5h
                0.5h
                Remaining:
                Remaining Estimate - 0.5h
                0.5h
                Logged:
                Time Spent - Not Specified
                Not Specified