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; }