Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Date & time (webpart) -> translate day, months View modes: 
User avatar
Member
Member
eagleag - 2/1/2011 3:29:51 AM
   
Date & time (webpart) -> translate day, months
Hi,
I'm using Date & time (webpar) on a multi culture site.
i would like for each culture to show the days of week and month in current culture.
example:
when on English site: Sunday
when on Hebrew site: ראשון

I looked at the file: DateTime.js
and saw this code:
dateFormat.i18n = {
dayNames: [
"Sun", "Mon", "Tue", "Wed", "Thr", "Fri", "Sat",
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
],
monthNames: [
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
]
};


understand that this is the place to and translations but not sure how to make it work?

after adding translation, where to i tell the code which lang to use?


many thanks :)



User avatar
Member
Member
kentico_michal - 2/3/2011 7:24:35 AM
   
RE:Date & time (webpart) -> translate day, months
Hi,

Regrettably, Date & Time web part does support translation. One possible work around could be loading DateTime.js dynamically depending on current culture (CMS.CMSHelper.CMSContext.CurrentDocumentCulture.CultureCode). So you could create multiple DateTime.js files (DateTime1.js, DateTime2.js), one for each culture with appropriate translations and use following code in SetupControl method of Date & Time web part (~\CMSWebParts\Viewers\DateTime.ascx.cs)


switch (CMS.CMSHelper.CMSContext.CurrentDocumentCulture.CultureCode)
{
case "en-US":
ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "datetime", "<script type=\"text/javascript\" src=\"" + ResolveUrl("~/CMSWebParts/Viewers/DateTime_files/DateTime1.js") + "\"></script>");
break;
case "cs-CZ":
ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "datetime", "<script type=\"text/javascript\" src=\"" + ResolveUrl("~/CMSWebParts/Viewers/DateTime_files/DateTime2.js") + "\"></script>");
break;
}


to invoke correct script instead of the default code:


ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "datetime", "<script type=\"text/javascript\" src=\"" + ResolveUrl("~/CMSWebParts/Viewers/DateTime_files/DateTime.js") + "\"></script>");


Best regards,
Michal Legen