PDA

View Full Version : [CLOSED] ext:CalendarPanel: Today is in English format, should be in Portuguese



supera
Mar 28, 2012, 11:22 AM
Hi

In CalendarPanel, Today is in English format: should be in Portuguese: Hoje, 13:50. In Brazil, we use the military time format.

See highilighted 2 on picture bellow.

4019

Daniil
Mar 28, 2012, 1:05 PM
Hi,

It's not localized automatically as well.

Regarding to "Today" text. There is the respective TodayText property of Views.

Regarding to the time format. It's more complicated, needs to override the scripts.

Here is the example.

Example

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Ext.NET v2 Example</title>

<ext:ResourcePlaceHolder runat="server" Mode="ScriptFiles" />

<script type="text/javascript">
Ext.calendar.template.BoxLayout.override({
getTodayText : function(){
var dt = Ext.Date.format(new Date(), 'l, F j, Y'),
todayText = this.showTodayText !== false ? this.todayText : '',
timeText = this.showTime !== false ? ' <span id="'+this.id+'-clock" class="ext-cal-dtitle-time">' +
//Ext.Date.format(new Date(), 'g:i a') + '</span>' : '',
Ext.Date.format(new Date(), 'H:i') + '</span>' : '',
separator = todayText.length > 0 || timeText.length > 0 ? ' &mdash; ' : '';

if(this.dayCount == 1){
return dt + separator + todayText + timeText;
}
fmt = this.weekCount == 1 ? 'D j' : 'j';
return todayText.length > 0 ? todayText + timeText : Ext.Date.format(new Date(), fmt) + timeText;
}
});

Ext.calendar.view.Month.override({
initClock: function() {
if (Ext.fly(this.id + '-clock') !== null) {
this.prevClockDay = new Date().getDay();
if (this.clockTask) {
Ext.TaskManager.stop(this.clockTask);
}
this.clockTask = Ext.TaskManager.start({
run: function() {
var el = Ext.fly(this.id + '-clock'),
t = new Date();

if (t.getDay() == this.prevClockDay) {
if (el) {
//el.update(Ext.Date.format(t, 'g:i a'));
el.update(Ext.Date.format(t, 'H:i'));
}
}
else {
this.prevClockDay = t.getDay();
this.moveTo(t);
}
},
scope: this,
interval: 1000
});
}
}
});
</script>
</head>
<body>
<ext:ResourceManager runat="server" Locale="pt-BR" />
<ext:Viewport runat="server" Layout="FitLayout">
<Items>
<ext:CalendarPanel ID="CalendarPanel1" runat="server">
<EventStore runat="server" />
<DayView runat="server" TodayText="Hoje" />
<WeekView runat="server" TodayText="Hoje" />
<MonthView runat="server" TodayText="Hoje" />
</ext:CalendarPanel>
</Items>
</ext:Viewport>
</body>
</html>

supera
Mar 28, 2012, 1:32 PM
Hi Daniil!

Thanks a lot for your scripts code... Works very well.