InstallOSLocale
Christopher James Lahey <[email protected]>
| Newsgroups | gmane.comp.web.galeon.devel |
|---|---|
| Message-ID | <[email protected]> |
So, I was working on making the mozilla internals in galeon match the
locale. I called this code fragment from mozilla_embed_class_init.
I've already sent this to Chris Blizzard. I hope it'll be included
directly in a future version of gtkmozembed, but I thought I'd send it
to you guys anyway.
Thanks,
Chris
#include <chrome/nsIChromeRegistry.h>
#include <locale/nsILocaleService.h>
static nsresult
getUILang(nsAString& aUILang)
{
nsresult result;
// get a locale service
nsCOMPtr<nsILocaleService> localeService = do_GetService(NS_LOCALESERVICE_CONTRACTID, &result);
NS_ASSERTION(NS_SUCCEEDED(result),"getUILang: get locale service failed");
nsXPIDLString uiLang;
result = localeService->GetLocaleComponentForUserAgent(getter_Copies(uiLang));
aUILang = uiLang;
return result;
}
// update global locale if possible (in case when user-*.rdf can be updated)
// so that any apps after this can be invoked in the UILocale and contentLocale
static nsresult InstallOSLocale(void)
{
nsresult rv = NS_OK;
nsAutoString uiLang;
// compute lang code
rv = getUILang(uiLang);
nsCOMPtr<nsIXULChromeRegistry> chromeRegistry = do_GetService(NS_CHROMEREGISTRY_CONTRACTID, &rv);
if (chromeRegistry) {
chromeRegistry->SetRuntimeProvider(PR_TRUE);
rv = chromeRegistry->SelectLocale(NS_ConvertUCS2toUTF8(uiLang), PR_FALSE);
}
return NS_OK;
}
-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
same time. Free trial click here: http://www.vmware.com/wl/offer/345/0