From 19d94da9825a49e5ce509cb6161e59883d0816d5 Mon Sep 17 00:00:00 2001 From: "valeski%netscape.com" Date: Mon, 13 Sep 1999 18:38:02 +0000 Subject: [PATCH] added user agent language portion initialization git-svn-id: svn://10.0.0.236/trunk@47138 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/base/nsWebShell.cpp | 23 +++++++++++++++++++++++ mozilla/webshell/src/nsWebShell.cpp | 23 +++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index e1c3ab39afd..c2615044399 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -78,6 +78,8 @@ #include "nsIRegistry.h" static NS_DEFINE_CID(kRegistryCID, NS_REGISTRY_CID); +#include "nsILocaleService.h" +static NS_DEFINE_CID(kLocaleServiceCID, NS_LOCALESERVICE_CID); #ifdef XP_PC #include @@ -1244,6 +1246,27 @@ nsWebShell::Init(nsNativeWidget aNativeParent, } // END STREAM CONVERTER REGISTRATION + // Set the language portion of the user agent. :) + nsILocaleService *localeServ; + rv = nsServiceManager::GetService(kLocaleServiceCID, NS_GET_IID(nsILocaleService), + (nsISupports**)&localeServ); + if (NS_FAILED(rv)) goto done; + + PRUnichar *UALang; + rv = localeServ->GetLocaleComponentForUserAgent(&UALang); + NS_RELEASE(localeServ); + if (NS_FAILED(rv)) goto done; + + nsIIOService *ioServ; + rv = nsServiceManager::GetService(kIOServiceCID, NS_GET_IID(nsIIOService), (nsISupports**)&ioServ); + if (NS_FAILED(rv)) goto done; + + rv = ioServ->SetLanguage(UALang); + nsAllocator::Free(UALang); + NS_RELEASE(ioServ); + if (NS_FAILED(rv)) goto done; + + done: return rv; } diff --git a/mozilla/webshell/src/nsWebShell.cpp b/mozilla/webshell/src/nsWebShell.cpp index e1c3ab39afd..c2615044399 100644 --- a/mozilla/webshell/src/nsWebShell.cpp +++ b/mozilla/webshell/src/nsWebShell.cpp @@ -78,6 +78,8 @@ #include "nsIRegistry.h" static NS_DEFINE_CID(kRegistryCID, NS_REGISTRY_CID); +#include "nsILocaleService.h" +static NS_DEFINE_CID(kLocaleServiceCID, NS_LOCALESERVICE_CID); #ifdef XP_PC #include @@ -1244,6 +1246,27 @@ nsWebShell::Init(nsNativeWidget aNativeParent, } // END STREAM CONVERTER REGISTRATION + // Set the language portion of the user agent. :) + nsILocaleService *localeServ; + rv = nsServiceManager::GetService(kLocaleServiceCID, NS_GET_IID(nsILocaleService), + (nsISupports**)&localeServ); + if (NS_FAILED(rv)) goto done; + + PRUnichar *UALang; + rv = localeServ->GetLocaleComponentForUserAgent(&UALang); + NS_RELEASE(localeServ); + if (NS_FAILED(rv)) goto done; + + nsIIOService *ioServ; + rv = nsServiceManager::GetService(kIOServiceCID, NS_GET_IID(nsIIOService), (nsISupports**)&ioServ); + if (NS_FAILED(rv)) goto done; + + rv = ioServ->SetLanguage(UALang); + nsAllocator::Free(UALang); + NS_RELEASE(ioServ); + if (NS_FAILED(rv)) goto done; + + done: return rv; }