Bug 330103 Remove hardcoded strings. Also removes extra debug code and fixes a strict warning about sharp variables. r=mvl

This commit is contained in:
jminta%gmail.com 2006-03-20 13:28:00 +00:00
parent 7ce2bbd1b9
commit 39272c9371
6 changed files with 40 additions and 35 deletions

View File

@ -383,18 +383,20 @@ function saveDialog(item)
function updateTitle()
{
// XXX make this use string bundles
var isNew = window.calendarItem.isMutable;
var sbs = Components.classes["@mozilla.org/intl/stringbundle;1"]
.getService(Components.interfaces.nsIStringBundleService);
var props = sbs.createBundle("chrome://calendar/locale/calendar.properties");
if (isEvent(window.calendarItem)) {
if (isNew)
document.title = "New Event";
document.title = props.GetStringFromName("newEventDialog");
else
document.title = "Edit Event";
document.title = props.GetStringFromName("editEventDialog");
} else if (isToDo(window.calendarItem)) {
if (isNew)
document.title = "New Task";
document.title = props.GetStringFromName("newTaskDialog");
else
document.title = "Edit Task";
document.title = props.GetStringFromName("editTaskDialog");
}
}

View File

@ -30,7 +30,6 @@
// refresh testing UI) the event buckets are emptied, and we add items as they
// arrive.
//
// This is currently a localization disaster. Quel dommage!
function Synthetic(title, open)
{
@ -39,18 +38,7 @@ function Synthetic(title, open)
this.events = [];
}
Synthetic.prototype.toString =
function toString()
{
return "[Synthetic: " + this.title + "/" + (this.open ? "open" : "closed") + "]";
};
var agendaTreeView = {
// This is the first time I've used sharp variables in earnest!
today: #1=(new Synthetic("Today", true)),
tomorrow: #2=(new Synthetic("Tomorrow", false)),
soon: #3=(new Synthetic("Soon", false)),
periods: [#1#, #2#, #3#],
events: [],
todayCount: 0,
tomorrowCount: 0,
@ -58,6 +46,19 @@ var agendaTreeView = {
prevRowCount: 0
};
agendaTreeView.init =
function initAgendaTree()
{
var sbs = Components.classes["@mozilla.org/intl/stringbundle;1"]
.getService(Components.interfaces.nsIStringBundleService);
var props = sbs.createBundle("chrome://lightning/locale/lightning.properties");
this.today = new Synthetic(props.GetStringFromName("agendaToday"), true);
this.tomorrow = new Synthetic(props.GetStringFromName("agendaTomorrow"), false);
this.soon = new Synthetic(props.GetStringFromName("agendaSoon"), false);
this.periods = [this.today, this.tomorrow, this.soon];
}
agendaTreeView.addEvents =
function addEvents(master)
{
@ -79,7 +80,6 @@ agendaTreeView.forceTreeRebuild =
function forceTreeRebuild()
{
if (this.tree) {
// dump("forcing tree rebuild\n");
this.tree.view = this;
}
};
@ -88,29 +88,18 @@ agendaTreeView.rebuildAgendaView =
function rebuildAgendaView(invalidate)
{
this.rebuildEventsArray();
/*
dump("events:\n");
this.events.forEach(function (e) {
if (e instanceof Synthetic)
dump(" " + e.title + "\n");
else
dump(" " + e.title + " @ " + e.occurrenceStartDate + "\n");
});
*/
this.forceTreeRebuild();
};
agendaTreeView.__defineGetter__("rowCount",
function get_rowCount()
{
//dump("row count: " + this.events.length + "\n");
return this.events.length;
});
agendaTreeView.isContainer =
function isContainer(row)
{
// dump("row " + row + " is " + this.events[row] + "\n")
return (this.events[row] instanceof Synthetic);
};
@ -118,7 +107,6 @@ agendaTreeView.isContainerOpen =
function isContainerOpen(row)
{
var open = this.events[row].open;
// dump("row " + row + " (" + this.events[row].title + ") is " + (open ? "open" : "closed") + "\n");
return open;
};
@ -448,6 +436,8 @@ function setCalendar(calendar)
this.calendar = calendar;
calendar.addObserver(this.calendarObserver);
this.init();
// Update everything
this.refreshPeriodDates();
};

View File

@ -190,7 +190,10 @@ var ltnCalendarViewController = {
var event = createEvent();
event.startDate = aStartTime;
event.endDate = aEndTime;
event.title = "New Event";
var sbs = Components.classes["@mozilla.org/intl/stringbundle;1"]
.getService(Components.interfaces.nsIStringBundleService);
var props = sbs.createBundle("chrome://calendar/locale/calendar.properties");
event.title = props.GetStringFromName("newEvent");
aCalendar.addItem(event, null);
} else if (aStartTime && aStartTime.isDate) {
var event = createEvent();

View File

@ -20,6 +20,7 @@ lightning.jar:
en-US.jar:
locale/en-US/lightning/lightning.dtd (locale/lightning.dtd)
locale/en-US/lightning/lightning.properties (locale/lightning.properties)
calendar.jar:
content/calendar/calendarProperties.xul (/calendar/resources/content/calendarProperties.xul)

View File

@ -55,10 +55,10 @@ calViewController.prototype.createNewEvent = function (aCalendar, aStartTime, aE
var event = createEvent();
event.startDate = aStartTime;
event.endDate = aEndTime;
//var bundle = srGetStrBundle("chrome://calendar/locale/calendar.properties");
//var newEventTitle = bundle.GetStringFromName("newEvent");
var newEventTitle = "New Event";
event.title = newEventTitle;
var sbs = Components.classes["@mozilla.org/intl/stringbundle;1"]
.getService(Components.interfaces.nsIStringBundleService);
var props = sbs.createBundle("chrome://calendar/locale/calendar.properties");
event.title = props.GetStringFromName("newEvent");
doTransaction('add', event, aCalendar, null, null);
} else if (aStartTime && aStartTime.isDate) {
var event = createEvent();

View File

@ -40,6 +40,15 @@
AllDayEvents=All Day Events
PrintPreviewWindowTitle=Print Preview of %1$S
# Default name for new events
newEvent=New Event
# Titles for the event/task dialog
newEventDialog=New Event
editEventDialog=Edit Event
newTaskDialog=New Task
editTaskDialog=Edit Task
# The name of the calendar provided with the application by default
homeCalendarName=Home