result = NewLocale(xpLocale.ToNewUnicode(),&mApplicationLocale);
loc = xpLocale.ToNewUnicode(); result = NewLocale(loc, &mApplicationLocale); nsCRT::free(loc);
nsLocaleService::nsLocaleService(void):	mSystemLocale(nsnull), mApplicationLocale(nsnull){	NS_INIT_REFCNT();#ifdef XP_PC	nsIWin32Locale*	win32Converter;	nsString		xpLocale;	nsresult result = nsComponentManager::CreateInstance(kWin32LocaleFactoryCID,						NULL,kIWin32LocaleIID,(void**)&win32Converter);	NS_ASSERTION(win32Converter!=NULL,"nsLocaleService: can't get win32 converter\n");	if (NS_SUCCEEDED(result) && win32Converter!=nsnull) {				//		// get the system LCID		//		LCID win_lcid = GetSystemDefaultLCID();		if (win_lcid==0) { win32Converter->Release(); return;}		result = win32Converter->GetXPLocale(win_lcid,&xpLocale);		if (NS_FAILED(result)) { win32Converter->Release(); return;}		result = NewLocale(xpLocale.ToNewUnicode(),&mSystemLocale);		if (NS_FAILED(result)) { win32Converter->Release(); return;}		//		// get the application LCID		//		win_lcid = GetUserDefaultLCID();		if (win_lcid==0) { win32Converter->Release(); return;}		result = win32Converter->GetXPLocale(win_lcid,&xpLocale);		if (NS_FAILED(result)) { win32Converter->Release(); return;}		result = NewLocale(xpLocale.ToNewUnicode(),&mApplicationLocale);		if (NS_FAILED(result)) { win32Converter->Release(); return;}			win32Converter->Release();	}#endif#ifdef XP_UNIX    nsIPosixLocale* posixConverter;    nsString xpLocale;    nsresult result = nsComponentManager::CreateInstance(kPosixLocaleFactoryCID,                           NULL,kIPosixLocaleIID,(void**)&posixConverter);    if (NS_SUCCEEDED(result) && posixConverter!=nsnull) {        char* lc_all = setlocale(LC_ALL,NULL);        char* lang = getenv("LANG");        if (lc_all!=nsnull) {            result = posixConverter->GetXPLocale(lc_all,&xpLocale);            if (NS_FAILED(result)) { posixConverter->Release(); return; }            result = NewLocale(xpLocale.ToNewUnicode(),&mSystemLocale);            if (NS_FAILED(result)) { posixConverter->Release(); return; }            mApplicationLocale=mSystemLocale;            mApplicationLocale->AddRef();            posixConverter->Release();        } else {            if (lang==nsnull) {                xpLocale = "en-US";                result = NewLocale(xpLocale.ToNewUnicode(),&mSystemLocale);                if (NS_FAILED(result)) { posixConverter->Release(); return; }                mApplicationLocale = mSystemLocale;                mApplicationLocale->AddRef();                posixConverter->Release();            } else {                int i;                nsString category;                nsLocale* resultLocale = new nsLocale();				if (resultLocale==NULL) { posixConverter->Release(); return; }                for(i=0;i<LocaleListLength;i++) {                    char* lc_temp = setlocale(posix_locale_category[i],"");                    category = LocaleList[i];                    if (lc_temp==nsnull) xpLocale = "en-US";                    else xpLocale = lc_temp;                    resultLocale->AddCategory(category.ToNewUnicode(),xpLocale.ToNewUnicode());                }                (void)resultLocale->QueryInterface(kILocaleIID,(void**)&mSystemLocale);                (void)resultLocale->QueryInterface(kILocaleIID,(void**)&mApplicationLocale);                posixConverter->Release();            }        }    }#endif // XP_PC#ifdef XP_MAC	long script = GetScriptManagerVariable(smSysScript);	long lang = GetScriptVariable(smSystemScript,smScriptLang);	long region = GetScriptManagerVariable(smRegionCode);	nsIMacLocale*	macConverter;	nsresult result = nsComponentManager::CreateInstance(kMacLocaleFactoryCID,						NULL,kIMacLocaleIID,(void**)&macConverter);	if (NS_SUCCEEDED(result) && macConverter!=nsnull) {		nsString xpLocale;		result = macConverter->GetXPLocale((short)script,(short)lang,(short)region,&xpLocale);		if (NS_FAILED(result)) { macConverter->Release(); return; }		result = NewLocale(xpLocale.ToNewUnicode(),&mSystemLocale);		if (NS_FAILED(result)) { macConverter->Release(); return; }		mApplicationLocale = mSystemLocale;		mApplicationLocale->AddRef();		macConverter->Release();	}#endif	                              }