Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    SmartClient 5.6 Patch for Localization of day names and month names

    In SmartClient version 5.6, the DateItem class displays 3 character day names and month names. These are English language abbreviations, which may be inappropriate for localized applications.
    This is a patch to simplify modifying the short day names and month names displayed by the SmartClient system in the date item (both in the drop down selector for months, and in the pop up 'calender' type selector).

    Once the patch code has been applied to your application,
    - to customize month names, set Date.shortMonthNames to an array of 12 month name strings.
    - to customize day names, set Date.shortDayNames to an array of 7 day name strings.

    This patch applies to the 5.6 Evaluation builds only.

    Code:
    //----------------------------------------------------------------------------
    // Isomorphic SmartClient v5.6 patch
    // Purpose: Allow customization of user visible Day Names and Month Names for
    //          localization of SmartClient applications.
    //----------------------------------------------------------------------------
    // Designed for use with the 5.6 build only
    if (window.isc && isc.version.contains("5.6/")) {
    isc.Log.logInfo("Installing 5.6 build Date Localization Patch");
    isc.addProperties(Date.prototype, {
    deriveShortDayName:Date.prototype.getShortDayName,
    getShortDayName:function () {return this.getShortDayNames()[this.getDay()]},
    getShortDayNames:function (length) {length = length || 3;var rawNames = Date.shortDayNames;
    if (rawNames == null) rawNames = Date._derivedShortDayNames;
    if (rawNames == null) {Date._derivedShortDayNames = [];var dateObj = new Date();dateObj.setDate(1);
    if (dateObj.getDay() > 0) dateObj.setDate(dateObj.getDate() + (7-dateObj.getDay()));
    var startDate = dateObj.getDate();
    for (var i = 0; i < 7; i++) {
    dateObj.setDate(startDate + i);
    Date._derivedShortDayNames[i] = dateObj.deriveShortDayName();
    }rawNames = Date._derivedShortDayNames;}
    var names = [];
    for (var i = 0; i < 7; i++) {names[i] = rawNames[i].substring(0,length);}return names;},
    deriveShortMonthName:Date.prototype.getShortMonthName,
    getShortMonthName:function () {return this.getShortMonthNames()[this.getMonth()];},
    getShortMonthNames : function (length) {length = length || 3;var rawNames = Date.shortMonthNames;
    if (rawNames == null) rawNames = Date._derivedShortMonthNames;if (rawNames == null) {var list = Date._derivedShortMonthNames = [];
    for (var i = 0; i < 12; i++) {var date = new Date(2000,i,1);list[i] = date.deriveShortMonthName();}
    rawNames = Date._derivedShortMonthNames;}
    var names = [];
    for (var i =0; i< 12; i++) {names[i] = rawNames[i].substring(0,length);}return names;}
    });
    isc.DateItem.mapCache={};
    }
    // End of Patch
    /////////////////////////////////////////////////////////////////////////////////////
Working...
X