Kendo - Unable to localize the string "TODAY" in the kendo date range component

Viewed 270

I am working on a Kendo grid where I am implementing localization and trying to translate all the visible text.

For instance I have manage to apply my translations on the kendo grid using the kendo grid message component as follow:

<kendo-grid-messages
        pagerPage="{{ 'PAGE' | translate }}"
        pagerOf="{{ 'OF' | translate }}"
        pagerItems="{{ 'ITEMS' | translate }}"
        pagerLastPage="{{ 'GO_TO_THE_LAST_PAGE' | translate }}"
        pagerNextPage="{{ 'GO_TO_THE_NEXT_PAGE' | translate }}"
        pagerPreviousPage="{{ 'GO_TO_THE_PREVIOUS_PAGE' | translate }}"
        pagerFirstPage="{{ 'GO_TO_THE_FIRST_PAGE' | translate }}"
        noRecords="{{ 'NO_RECORDS_AVAILABLE' | translate }}">
  </kendo-grid-messages>

In that way I have managed to my own translations - great.

Similar thing done for a dropdown:

<kendo-dropdownlist-messages
    noDataText="{{ 'NO_DATA_FOUND' | translate }}"
  >
</kendo-dropdownlist-messages>

Fantastic!! Both those html element are inside their respective parents.

Now I have got a kendo-filter-date-range within my grid that looks like this:

<ng-template *ngIf="column.type === 'date'" kendoGridFilterCellTemplate let-filter let-column="column">
    <reporting-date-range-filter class="date-range-filter k-filtercell" [filter]="filter" [field]="column.field"
      [dateFormat]="dateFormat">
    </reporting-date-range-filter>
  </ng-template>

when drilling into the actual component I get in the following code:

<div class="date-filter-container">
  <kendo-daterange>
   <kendo-dateinput class="range-filter" kendoDateRangeStartInput formatPlaceholder="short" [format]="dateFormat"
  [value]="start" (valueChange)="filterRange($event, end)">
   </kendo-dateinput>-
   <kendo-dateinput class="range-filter" kendoDateRangeEndInput formatPlaceholder="short" [format]="dateFormat"
  [value]="end" (valueChange)="filterRange(start, $event)">
   </kendo-dateinput>
  </kendo-daterange>
  <button *ngIf="hasFilter" class="k-button k-button-icon" title="{{'CLEAR' | translate}}" (click)="clearFilter()">
  <span class="k-icon k-i-filter-clear"></span>
  </button>
</div>

As you can see I have applied my translation to the Clear button.

This is what it looks like at the moment: enter image description here

I have not manually translated the attributes in that calendar (days, months) but it automatically picked up the current user language.

Now what I am struggling with it's to change the text in the button "TODAY" to Chinese in my case.

  • I cannot find any custom message component for kendo-daterange
  • kendo-datepicker-messages seems like the only one containing the "today" attribute but changing all the once I have found in the system did not updated that calendar.

I'll be glad to know if anyone has ever localizated that text. Thank you

1 Answers

The DateRange has an additional component that controls the calendars in popup. It is called MultiViewCalendar.

I think this should do the trick for your case, you can ignore the min and max dates:

<kendo-daterange>
    <div class="form-group d-inline-block">
        <label class="label-control" [translate]="'dateFrom'"></label>
        <div class="d-inline-block"><kendo-dateinput class="form-control"  kendoDateRangeStartInput [(value)]="range.start"></kendo-dateinput></div>
    </div>
    <div class="form-group d-inline-block">
        <label class="label-control" [translate]="'dateTo'"></label>
        <div class="d-inline-block"><kendo-dateinput class="form-control" kendoDateRangeEndInput [(value)]="range.end"></kendo-dateinput></div>
    </div>
    <kendo-daterange-popup>
      <ng-template kendoDateRangePopupTemplate>
          <kendo-multiviewcalendar kendoDateRangeSelection [min]="minDate" [max]="maxDate">
            <kendo-multiviewcalendar-messages today="yourTranslation"></kendo-multiviewcalendar-messages>
          </kendo-multiviewcalendar>
      </ng-template>
  </kendo-daterange-popup>
</kendo-daterange>
Related