Files
Mozilla/mozilla/mailnews/compose/src/nsMsgComposeStringBundle.cpp
rhp%netscape.com 36967dbd03 Fixes for file - save as in unicode and spaces in replies becoming unprintable chars - Bug #: 23418 - 29267 - r: jefft
git-svn-id: svn://10.0.0.236/trunk@61852 18797224-902f-48f8-a5cc-f745e15eee43
2000-02-29 07:04:24 +00:00

81 lines
2.2 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "prprf.h"
#include "prmem.h"
#include "nsCOMPtr.h"
#include "nsIStringBundle.h"
#include "nsMsgComposeStringBundle.h"
#include "nsIServiceManager.h"
#include "nsIPref.h"
#include "nsIIOService.h"
#include "nsIURI.h"
#include "msgCore.h"
/* This is the next generation string retrieval call */
static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
#define COMPOSE_BE_URL "chrome://messengercompose/locale/composeMsgs.properties"
extern "C"
PRUnichar *
ComposeGetStringByID(PRInt32 stringID)
{
nsresult res;
char* propertyURL = NULL;
nsString resultString = "???";
propertyURL = COMPOSE_BE_URL;
NS_WITH_SERVICE(nsIStringBundleService, sBundleService, kStringBundleServiceCID, &res);
if (NS_SUCCEEDED(res) && (nsnull != sBundleService))
{
nsILocale *locale = nsnull;
nsIStringBundle* sBundle = nsnull;
res = sBundleService->CreateBundle(propertyURL, locale, &sBundle);
if (NS_SUCCEEDED(res))
{
PRUnichar *ptrv = nsnull;
if (NS_IS_MSG_ERROR(stringID))
stringID = NS_ERROR_GET_CODE(stringID);
res = sBundle->GetStringFromID(stringID, &ptrv);
NS_RELEASE(sBundle);
if (NS_FAILED(res))
{
resultString = "[StringID(hex)=";
resultString.Append(stringID, 16);
resultString += "?]";
return resultString.ToNewUnicode();
}
return ptrv;
}
}
return resultString.ToNewUnicode();
}