| 1 | /* |
|---|
| 2 | * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
|---|
| 3 | * |
|---|
| 4 | * This library is free software; you can redistribute it and/or |
|---|
| 5 | * modify it under the terms of the GNU Library General Public |
|---|
| 6 | * License as published by the Free Software Foundation; either |
|---|
| 7 | * version 2 of the License, or (at your option) any later version. |
|---|
| 8 | * |
|---|
| 9 | * This library is distributed in the hope that it will be useful, |
|---|
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 12 | * Library General Public License for more details. |
|---|
| 13 | * |
|---|
| 14 | * You should have received a copy of the GNU Library General Public License |
|---|
| 15 | * along with this library; see the file COPYING.LIB. If not, write to |
|---|
| 16 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|---|
| 17 | * Boston, MA 02110-1301, USA. |
|---|
| 18 | */ |
|---|
| 19 | |
|---|
| 20 | #include "config.h" |
|---|
| 21 | #include "Language.h" |
|---|
| 22 | |
|---|
| 23 | #include "CString.h" |
|---|
| 24 | #include "PlatformString.h" |
|---|
| 25 | |
|---|
| 26 | #include <gtk/gtk.h> |
|---|
| 27 | #include <pango/pango.h> |
|---|
| 28 | |
|---|
| 29 | #if !defined(PANGO_VERSION_CHECK) |
|---|
| 30 | // PANGO_VERSION_CHECK() and pango_language_get_default() appeared in 1.5.2 |
|---|
| 31 | #include <locale.h> |
|---|
| 32 | |
|---|
| 33 | static gchar * |
|---|
| 34 | _pango_get_lc_ctype (void) |
|---|
| 35 | { |
|---|
| 36 | return g_strdup (setlocale (LC_CTYPE, NULL)); |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | static PangoLanguage * |
|---|
| 40 | pango_language_get_default (void) |
|---|
| 41 | { |
|---|
| 42 | static PangoLanguage *result = NULL; |
|---|
| 43 | if (G_UNLIKELY (!result)) |
|---|
| 44 | { |
|---|
| 45 | gchar *lang = _pango_get_lc_ctype (); |
|---|
| 46 | result = pango_language_from_string (lang); |
|---|
| 47 | g_free (lang); |
|---|
| 48 | } |
|---|
| 49 | return result; |
|---|
| 50 | } |
|---|
| 51 | #endif |
|---|
| 52 | |
|---|
| 53 | namespace WebCore { |
|---|
| 54 | |
|---|
| 55 | String defaultLanguage() |
|---|
| 56 | { |
|---|
| 57 | return pango_language_to_string(gtk_get_default_language()); |
|---|
| 58 | } |
|---|
| 59 | |
|---|
| 60 | } |
|---|