From cac0f67c402d107cdb10971b95719e2ff9c7c76b Mon Sep 17 00:00:00 2001 From: Steve Block Date: Thu, 5 Nov 2009 09:23:40 +0000 Subject: Merge webkit.org at r50258 : Initial merge by git. Change-Id: I1a9e1dc4ed654b69174ad52a4f031a07240f37b0 --- WebCore/platform/gtk/Language.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'WebCore/platform/gtk/Language.cpp') diff --git a/WebCore/platform/gtk/Language.cpp b/WebCore/platform/gtk/Language.cpp index 171cd84..fea2df6 100644 --- a/WebCore/platform/gtk/Language.cpp +++ b/WebCore/platform/gtk/Language.cpp @@ -21,16 +21,37 @@ #include "Language.h" #include "CString.h" +#include "GOwnPtr.h" #include "PlatformString.h" #include +#include #include namespace WebCore { +// Using pango_language_get_default() here is not an option, because +// it doesn't support changing the locale in runtime, so it returns +// always the same value. String defaultLanguage() { - return pango_language_to_string(gtk_get_default_language()); + char* localeDefault = setlocale(LC_CTYPE, NULL); + + if (!localeDefault) + return String("c"); + + GOwnPtr normalizedDefault(g_ascii_strdown(localeDefault, -1)); + char* ptr = strchr(normalizedDefault.get(), '_'); + + if(ptr) + *ptr = '-'; + + ptr = strchr(normalizedDefault.get(), '.'); + + if(ptr) + *ptr = '\0'; + + return String(normalizedDefault.get()); } } -- cgit v1.1