nsILocale integration.

This commit is contained in:
nhotta%netscape.com 1999-02-16 19:05:10 +00:00
parent 209e55e7f2
commit a17c12c401
2 changed files with 31 additions and 6 deletions

View File

@ -23,7 +23,7 @@
#include "prmem.h"
#include "prmon.h"
NS_DEFINE_IID(kICollationIID, NS_ICOLLATION_IID);
static NS_DEFINE_IID(kICollationIID, NS_ICOLLATION_IID);
////////////////////////////////////////////////////////////////////////////////
@ -125,8 +125,20 @@ nsresult nsCollationMac::Initialize(nsILocale* locale)
// locale -> script code + charset name
// TODO: get this via nsILocale
mCharset.SetString("ISO-8859-1");
m_scriptcode = 0; //smRoman
mCharset.SetString("ISO-8859-1"); //TODO: should be "MacRoman"
if (locale != nsnull) {
nsString aLocale;
nsString aCategory("NSILOCALE_COLLATE");
nsresult res = locale->GetCatagory(&aCategory, &aLocale);
if (NS_FAILED(res)) {
return res;
}
//TODO: GetPlatformLocale() to get a script code when it's ready.
//TODO: Get a charset name from a script code.
}
// Initialize a mapping table for the script code.
if (mac_sort_tbl_init(m_scriptcode, m_mac_sort_tbl) == -1) {
return NS_ERROR_FAILURE;
}

View File

@ -188,7 +188,7 @@ static void AbbrevWeekdayString(DateTimeRec &dateTime, Str255 weekdayString, Int
////////////////////////////////////////////////////////////////////////////////
NS_DEFINE_IID(kIDateTimeFormatIID, NS_IDATETIMEFORMAT_IID);
static NS_DEFINE_IID(kIDateTimeFormatIID, NS_IDATETIMEFORMAT_IID);
NS_IMPL_ISUPPORTS(nsDateTimeFormatMac, kIDateTimeFormatIID);
@ -212,6 +212,9 @@ nsresult nsDateTimeFormatMac::FormatTMTime(nsILocale* locale,
DateTimeRec macDateTime;
Str255 timeString, dateString;
int32 dateTime;
long scriptcode = 0; //TODO: need to get this from locale
nsString aCharset("ISO-8859-1"); //TODO: should be "MacRoman", need to get this from locale
nsresult res;
// return, nothing to format
if (dateFormatSelector == kDateFormatNone && timeFormatSelector == kTimeFormatNone) {
@ -246,7 +249,19 @@ nsresult nsDateTimeFormatMac::FormatTMTime(nsILocale* locale,
::DateToSeconds( &macDateTime, (unsigned long *) &dateTime);
long scriptcode = 0; //TODO: need to get this from locale
// Get a script code and a charset name
if (locale != nsnull) {
nsString aLocale;
nsString aCategory("NSILOCALE_TIME");
nsresult res = locale->GetCatagory(&aCategory, &aLocale);
if (NS_FAILED(res)) {
return res;
}
//TODO: GetPlatformLocale() to get a script code when it's ready.
//TODO: Get a charset name from a script code.
}
Handle itl1Handle = (Handle) GetItl1Resource(scriptcode);
Handle itl0Handle = (Handle) GetItl0Resource(scriptcode);
NS_ASSERTION(itl1Handle && itl0Handle, "failed to get itl handle");
@ -303,8 +318,6 @@ nsresult nsDateTimeFormatMac::FormatTMTime(nsILocale* locale,
// convert result to unicode
nsresult res;
nsString aCharset("ISO-8859-1"); //TODO: need to get this from locale
nsICharsetConverterManager * ccm = nsnull;
res = nsServiceManager::GetService(kCharsetConverterManagerCID,