Bug 74714 don't hardcode "KB"/"MB" in MailNews

patch by mark@standard8.demon.co.uk r=neil sr=bienvenu


git-svn-id: svn://10.0.0.236/trunk@165020 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
timeless%mozdev.org 2004-11-05 18:08:34 +00:00
parent c980621750
commit a827e14d8e
5 changed files with 57 additions and 17 deletions

View File

@ -330,4 +330,9 @@ confirmResetJunkTrainingText=Are you sure you want to reset the adaptive filter
editVirtualFolderPropertiesTitle=Edit Saved Search Properties for %S
#alert to inform the user to choose one or more folders to search for a saved search folder
alertNoSearchFoldersSelected=You must choose at least one folder to search for the saved search folder.
alertNoSearchFoldersSelected=You must choose at least one folder to search for the saved search folder.
# These two are displayed in the message and folder pane windows
# LOCALIZATION NOTES(????ByteAbbreviation): Do not translate %d below, it is the size of the message/folder
kiloByteAbbreviation=%dKB
megaByteAbbreviation=%dMB

View File

@ -66,6 +66,7 @@
#include "nsISpamSettings.h"
#include "nsIMsgAccountManager.h"
#include "nsITreeColumns.h"
#include "nsTextFormatter.h"
static NS_DEFINE_CID(kDateTimeFormatCID, NS_DATETIMEFORMAT_CID);
@ -111,6 +112,8 @@ PRUnichar * nsMsgDBView::kRepliedString = nsnull;
PRUnichar * nsMsgDBView::kForwardedString = nsnull;
PRUnichar * nsMsgDBView::kNewString = nsnull;
PRUnichar * nsMsgDBView::kKiloByteString = nsnull;
nsDateFormatSelector nsMsgDBView::m_dateFormatDefault = kDateFormatShort;
nsDateFormatSelector nsMsgDBView::m_dateFormatThisWeek = kDateFormatShort;
nsDateFormatSelector nsMsgDBView::m_dateFormatToday = kDateFormatNone;
@ -205,6 +208,8 @@ void nsMsgDBView::InitializeAtomsAndLiterals()
kRepliedString = GetString(NS_LITERAL_STRING("replied").get());
kForwardedString = GetString(NS_LITERAL_STRING("forwarded").get());
kNewString = GetString(NS_LITERAL_STRING("new").get());
kKiloByteString = GetString(NS_LITERAL_STRING("kiloByteAbbreviation").get());
}
nsMsgDBView::~nsMsgDBView()
@ -255,6 +260,8 @@ nsMsgDBView::~nsMsgDBView()
nsCRT::free(kRepliedString);
nsCRT::free(kForwardedString);
nsCRT::free(kNewString);
nsCRT::free(kKiloByteString);
}
}
@ -711,13 +718,15 @@ nsresult nsMsgDBView::FetchSize(nsIMsgHdr * aHdr, PRUnichar ** aSizeString)
PRUint32 sizeInKB = msgSize/1024;
formattedSizeString.AppendInt(sizeInKB);
// XXX todo, fix this hard coded string?
formattedSizeString.AppendLiteral("KB");
// kKiloByteString is a localized string that we use to get the right
// format to add on the "KB" or equivalent
nsTextFormatter::ssprintf(formattedSizeString,
kKiloByteString,
sizeInKB);
}
*aSizeString = ToNewUnicode(formattedSizeString);
return NS_OK;
return (*aSizeString) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
nsresult nsMsgDBView::FetchPriority(nsIMsgHdr *aHdr, PRUnichar ** aPriorityString)

View File

@ -148,6 +148,8 @@ protected:
static PRUnichar* kForwardedString;
static PRUnichar* kNewString;
static PRUnichar* kKiloByteString;
nsCOMPtr<nsITreeBoxObject> mTree;
nsCOMPtr<nsITreeSelection> mTreeSelection;
PRUint32 mNumSelectedRows; // we cache this to determine when to push command status notifications.

View File

@ -65,6 +65,10 @@
#include "nsIMsgFolder.h" // TO include biffState enum. Change to bool later...
#include "nsArray.h"
#include "nsIPop3IncomingServer.h"
#include "nsTextFormatter.h"
#include "nsIStringBundle.h"
#define MESSENGER_STRING_URL "chrome://messenger/locale/messenger.properties"
nsIRDFResource* nsMsgFolderDataSource::kNC_Child = nsnull;
nsIRDFResource* nsMsgFolderDataSource::kNC_Folder= nsnull;
@ -134,6 +138,9 @@ nsIAtom * nsMsgFolderDataSource::kIsDeferredAtom = nsnull;
nsIAtom * nsMsgFolderDataSource::kCanFileMessagesAtom = nsnull;
nsIAtom * nsMsgFolderDataSource::kInVFEditSearchScopeAtom = nsnull;
PRUnichar * nsMsgFolderDataSource::kKiloByteString = nsnull;
PRUnichar * nsMsgFolderDataSource::kMegaByteString = nsnull;
static const PRUint32 kDisplayBlankCount = 0xFFFFFFFE;
static const PRUint32 kDisplayQuestionCount = 0xFFFFFFFF;
@ -143,6 +150,9 @@ nsMsgFolderDataSource::nsMsgFolderDataSource()
nsIRDFService* rdf = getRDFService();
if (gFolderResourceRefCnt++ == 0) {
nsresult res = NS_OK;
nsCOMPtr<nsIStringBundle> sMessengerStringBundle;
rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_CHILD), &kNC_Child);
rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_FOLDER), &kNC_Folder);
rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_NAME), &kNC_Name);
@ -208,6 +218,20 @@ nsMsgFolderDataSource::nsMsgFolderDataSource()
kIsDeferredAtom = NS_NewAtom("isDeferred");
kCanFileMessagesAtom = NS_NewAtom("canFileMessages");
kInVFEditSearchScopeAtom = NS_NewAtom("inVFEditSearchScope");
nsCOMPtr<nsIStringBundleService> sBundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &res);
if (NS_SUCCEEDED(res) && sBundleService)
res = sBundleService->CreateBundle(MESSENGER_STRING_URL, getter_AddRefs(sMessengerStringBundle));
if (NS_SUCCEEDED(res) && sMessengerStringBundle)
{
if (!NS_SUCCEEDED(sMessengerStringBundle->GetStringFromName(NS_LITERAL_STRING("kiloByteAbbreviation").get(), &kKiloByteString)))
kKiloByteString = ToNewUnicode(NS_LITERAL_STRING("kiloByteAbbreviation"));
if (!NS_SUCCEEDED(sMessengerStringBundle->GetStringFromName(NS_LITERAL_STRING("megaByteAbbreviation").get(), &kMegaByteString)))
kMegaByteString = ToNewUnicode(NS_LITERAL_STRING("megaByteAbbreviation"));
}
}
CreateLiterals(rdf);
@ -282,7 +306,10 @@ nsMsgFolderDataSource::~nsMsgFolderDataSource (void)
NS_RELEASE(kOpenAtom);
NS_RELEASE(kIsDeferredAtom);
NS_RELEASE(kCanFileMessagesAtom);
NS_RELEASE(kInVFEditSearchScopeAtom);
NS_RELEASE(kInVFEditSearchScopeAtom);
nsMemory::Free(kKiloByteString);
nsMemory::Free(kMegaByteString);
}
}
@ -1900,17 +1927,11 @@ nsMsgFolderDataSource::GetFolderSizeNode(PRInt32 aFolderSize, nsIRDFNode **aNode
folderSize = 1024; // make at least 1 k;
folderSize /= 1024; // normalize into k;
PRBool sizeInMB = (folderSize > 1024);
sizeString.AppendInt((sizeInMB) ? folderSize / 1024 : folderSize);
// On OS/2, we have an issue where temporaries get destructed in
// conditionals. Solution is to break it out
//
// XXX todo
// can we catch this problem at compile time?
// see #179234
if (sizeInMB)
sizeString.AppendLiteral(" MB");
else
sizeString.AppendLiteral(" KB");
// kKiloByteString/kMegaByteString are localized strings that we use
// to get the right format to add on the "KB"/"MB" or equivalent
nsTextFormatter::ssprintf(sizeString,
(sizeInMB) ? kMegaByteString : kKiloByteString,
(sizeInMB) ? folderSize / 1024 : folderSize);
createNode(sizeString.get(), aNode, getRDFService());
}
return NS_OK;

View File

@ -290,6 +290,9 @@ protected:
nsCOMPtr<nsISupportsArray> kFolderArcsOutArray;
static PRUnichar* kKiloByteString;
static PRUnichar* kMegaByteString;
};