Update to gtkspell3's iso code lookup

This no longer requires libxml
so now there is no reason for this to be optional
This commit is contained in:
TingPing 2013-10-01 12:09:17 -04:00
parent eb93130cd3
commit f6dd61cb02
6 changed files with 250 additions and 313 deletions

View File

@ -3,9 +3,10 @@
#define USE_GMODULE
#define USE_PLUGIN
#define USE_OPENSSL
#define USE_SPELL
#define USE_IPV6
#define HAVE_ISO_CODES
#define ISO_CODES_PREFIX ".\\"
#define ISO_CODES_LOCALEDIR LOCALEDIR
#define PACKAGE_NAME "hexchat"
#define PACKAGE_VERSION "2.9.6"
#define HEXCHATLIBDIR ".\\plugins"

View File

@ -41,7 +41,6 @@ AH_VERBATIM([HEXCHATSHAREDIR],[#undef HEXCHATSHAREDIR])
AH_VERBATIM([SOCKS],[#undef SOCKS])
AH_VERBATIM([USE_MSPROXY],[#undef USE_MSPROXY])
AH_VERBATIM([USE_LIBPROXY],[#undef USE_LIBPROXY])
AH_VERBATIM([USE_SPELL],[#undef USE_SPELL])
AH_VERBATIM([HAVE_ISO_CODES],[#undef HAVE_ISO_CODES])
AH_VERBATIM([USE_LIBNOTIFY],[#undef USE_LIBNOTIFY])
AH_VERBATIM([USE_LIBCANBERRA],[#undef USE_LIBCANBERRA])
@ -143,10 +142,6 @@ AC_ARG_ENABLE(libcanberra,
[AS_HELP_STRING([--disable-libcanberra],[disable libcanberra support])],
libcanberra=$enableval, libcanberra=yes)
AC_ARG_ENABLE(spell,
[AS_HELP_STRING([--enable-spell],[enable spellcheck, (default: yes)])],
spell=$enableval, spell=yes)
AC_ARG_ENABLE(ntlm,
[AS_HELP_STRING([--enable-ntlm],[enable Microsoft\'s NTLM auth (libntlm) library support (default: no)])],
ntlm=$enableval, ntlm=no)
@ -539,15 +534,12 @@ dnl *********************************************************************
dnl ** SPELL ************************************************************
dnl *********************************************************************
if test "$spell" = "xyes" ; then
PKG_CHECK_MODULES(LIBXML2, libxml-2.0 >= 2.0.0, [
AC_DEFINE(HAVE_ISO_CODES)
AC_DEFINE(USE_SPELL)
GUI_CFLAGS="$GUI_CFLAGS $LIBXML2_CFLAGS"
LIBS="$LIBS -lxml2"
], [
AC_MSG_ERROR(Cannot find libxml2!)
])
if test "$gtkfe" = "xyes" ; then
iso_codes_prefix=`$PKG_CONFIG --variable=prefix iso-codes 2>/dev/null || echo /usr`
AC_MSG_NOTICE([iso-codes prefix: $iso_codes_prefix])
AC_DEFINE_UNQUOTED([ISO_CODES_PREFIX], ["$iso_codes_prefix"], [ISO codes prefix])
AC_DEFINE_UNQUOTED([ISO_CODES_LOCALEDIR], ["$iso_codes_prefix/share/locale"], [ISO codes locale dir])
AC_DEFINE([HAVE_ISO_CODES], [1], [iso-codes available])
fi
dnl *********************************************************************
@ -555,7 +547,6 @@ dnl ** CONDITIONALS *****************************************************
dnl *********************************************************************
AM_CONDITIONAL(USE_OPENSSL, test "x$openssl" = "xyes")
AM_CONDITIONAL(USE_SPELL, test "x$spell" = "xyes")
AM_CONDITIONAL(USE_LIBNOTIFY, test "x$libnotify" = "xyes")
AM_CONDITIONAL(USE_LIBCANBERRA, test "x$libcanberra" = "xyes")
AM_CONDITIONAL(DO_TEXT, test "x$textfe" = "xyes")
@ -818,7 +809,6 @@ echo OpenSSL support ....... : $openssl
echo D-Bus support ......... : $dbus
echo libnotify support ..... : $libnotify
echo libcanberra support ... : $libcanberra
echo Spelling .............. : $spell
echo Plugin interface ...... : $plugin
echo NLS/gettext ........... : $USE_NLS
echo IPv6 support .......... : $ipv6

View File

@ -189,14 +189,12 @@ static const setting inputbox_settings[] =
{ST_TOGGLE, N_("Use the Text box font and colors"), P_OFFINTNL(hex_gui_input_style),0,0,0},
{ST_TOGGLE, N_("Show nick box"), P_OFFINTNL(hex_gui_input_nick),0,0,1},
{ST_TOGGLE, N_("Show user mode icon in nick box"), P_OFFINTNL(hex_gui_input_icon),0,0,0},
#ifdef USE_SPELL
{ST_TOGGLE, N_("Spell checking"), P_OFFINTNL(hex_gui_input_spell),0,0,1},
{ST_ENTRY, N_("Dictionaries to use:"), P_OFFSETNL(hex_text_spell_langs),0,0,sizeof prefs.hex_text_spell_langs},
#ifdef WIN32
{ST_LABEL, N_("Use language codes (as in \"share\\myspell\\dicts\").\nSeparate multiple entries with commas.")},
{ST_LABEL, N_("Use language codes (as in \"%LOCALAPPDATA%\\enchant\\myspell\\dicts\").\nSeparate multiple entries with commas.")},
#else
{ST_LABEL, N_("Use language codes. Separate multiple entries with commas.")},
#endif
#endif
{ST_HEADER, N_("Nick Completion"),0,0,0},
@ -2021,13 +2019,11 @@ setup_apply_to_sess (session_gui *gui)
else
gtk_widget_hide (gui->button_box);
#ifdef USE_SPELL
/* update active languages */
sexy_spell_entry_deactivate_language((SexySpellEntry *)gui->input_box,NULL);
sexy_spell_entry_activate_default_languages((SexySpellEntry *)gui->input_box);
sexy_spell_entry_set_checked ((SexySpellEntry *)gui->input_box, prefs.hex_gui_input_spell);
#endif
}
static void

View File

@ -1,307 +1,230 @@
/*
* Copyright (C) 2005 Nathan Fredrickson
* Borrowed from Galeon, renamed, and simplified to only use iso-codes with no
* fallback method.
*
* Copyright (C) 2004 Christian Persch
* Copyright (C) 2004 Crispin Flowerday
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
/* gtkspell - a spell-checking addon for GTK's TextView widget
* Copyright (c) 2013 Sandro Mani
*
* Based on gtkhtml-editor-spell-language.c code which is
* Copyright (C) 2008 Novell, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifdef WIN32
#include "sexy-iso-codes.h"
#include <libintl.h>
#include <string.h>
#ifdef G_OS_WIN32
#include "../../config-win32.h"
#else
#include "../../config.h"
#endif
#include "sexy-iso-codes.h"
#include <glib/gi18n.h>
#include <string.h>
#include <libxml/xmlreader.h>
#define ISO_639_DOMAIN "iso_639"
#define ISO_3166_DOMAIN "iso_3166"
static GHashTable *iso_639_table = NULL;
static GHashTable *iso_3166_table = NULL;
#define ISO_639_DOMAIN "iso_639"
#define ISO_3166_DOMAIN "iso_3166"
#ifdef HAVE_ISO_CODES
#define ISOCODESLOCALEDIR "/share/locale"
static void
read_iso_639_entry (xmlTextReaderPtr reader,
GHashTable *table)
iso_639_start_element (GMarkupParseContext *context,
const gchar *element_name,
const gchar **attribute_names,
const gchar **attribute_values,
gpointer data,
GError **error)
{
xmlChar *code, *name;
GHashTable *hash_table = data;
const gchar *name = NULL;
const gchar *code = NULL;
int i;
code = xmlTextReaderGetAttribute (reader, (const xmlChar *) "iso_639_1_code");
name = xmlTextReaderGetAttribute (reader, (const xmlChar *) "name");
if (strcmp (element_name, "iso_639_entry") != 0)
return;
/* Get iso-639-2 code */
if (code == NULL || code[0] == '\0')
for (i = 0; attribute_names[i] != NULL; i++)
{
xmlFree (code);
/* FIXME: use the 2T or 2B code? */
code = xmlTextReaderGetAttribute (reader, (const xmlChar *) "iso_639_2T_code");
if (strcmp (attribute_names[i], "name") == 0)
name = attribute_values[i];
else if (strcmp (attribute_names[i], "iso_639_1_code") == 0)
code = attribute_values[i];
}
if (code != NULL && code[0] != '\0' && name != NULL && name[0] != '\0')
{
g_hash_table_insert (table, code, name);
}
else
{
xmlFree (code);
xmlFree (name);
}
if (code != NULL && *code != '\0' && name != NULL && *name != '\0')
g_hash_table_insert (hash_table, g_strdup (code),
g_strdup (dgettext (ISO_639_DOMAIN, name)));
}
static void
read_iso_3166_entry (xmlTextReaderPtr reader,
GHashTable *table)
iso_3166_start_element (GMarkupParseContext *context,
const gchar *element_name,
const gchar **attribute_names,
const gchar **attribute_values,
gpointer data,
GError **error)
{
xmlChar *code, *name;
GHashTable *hash_table = data;
const gchar *name = NULL;
const gchar *code = NULL;
int i;
code = xmlTextReaderGetAttribute (reader, (const xmlChar *) "alpha_2_code");
name = xmlTextReaderGetAttribute (reader, (const xmlChar *) "name");
if (strcmp (element_name, "iso_3166_entry") != 0)
return;
if (code != NULL && code[0] != '\0' && name != NULL && name[0] != '\0')
for (i = 0; attribute_names[i] != NULL; i++)
{
char *lcode;
lcode = g_ascii_strdown ((char *) code, -1);
xmlFree (code);
g_hash_table_insert (table, lcode, name);
}
else
{
xmlFree (code);
xmlFree (name);
if (strcmp (attribute_names[i], "name") == 0)
name = attribute_values[i];
else if (strcmp (attribute_names[i], "alpha_2_code") == 0)
code = attribute_values[i];
}
if (code != NULL && *code != '\0' && name != NULL && *name != '\0')
g_hash_table_insert (hash_table, g_strdup (code),
g_strdup (dgettext (ISO_3166_DOMAIN, name)));
}
typedef enum
static void
iso_codes_parse (const GMarkupParser *parser,
const gchar *basename,
GHashTable *hash_table)
{
STATE_START,
STATE_STOP,
STATE_ENTRIES,
} ParserState;
static gboolean
load_iso_entries (int iso,
GFunc read_entry_func,
gpointer user_data)
{
xmlTextReaderPtr reader;
ParserState state = STATE_START;
xmlChar iso_entries[32], iso_entry[32];
char *filename;
int ret = -1;
#ifdef WIN32
filename = g_strdup_printf (".\\share\\xml\\iso-codes\\iso_%d.xml", iso);
#else
filename = g_strdup_printf ("/usr/share/xml/iso-codes/iso_%d.xml", iso);
#endif
reader = xmlNewTextReaderFilename (filename);
if (reader == NULL) goto out;
xmlStrPrintf (iso_entries, sizeof (iso_entries),
(xmlChar *)"iso_%d_entries", iso);
xmlStrPrintf (iso_entry, sizeof (iso_entry),
(xmlChar *)"iso_%d_entry", iso);
ret = xmlTextReaderRead (reader);
while (ret == 1)
{
const xmlChar *tag;
xmlReaderTypes type;
tag = xmlTextReaderConstName (reader);
type = xmlTextReaderNodeType (reader);
if (state == STATE_ENTRIES &&
type == XML_READER_TYPE_ELEMENT &&
xmlStrEqual (tag, iso_entry))
{
read_entry_func (reader, user_data);
}
else if (state == STATE_START &&
type == XML_READER_TYPE_ELEMENT &&
xmlStrEqual (tag, iso_entries))
{
state = STATE_ENTRIES;
}
else if (state == STATE_ENTRIES &&
type == XML_READER_TYPE_END_ELEMENT &&
xmlStrEqual (tag, iso_entries))
{
state = STATE_STOP;
}
else if (type == XML_READER_TYPE_SIGNIFICANT_WHITESPACE ||
type == XML_READER_TYPE_WHITESPACE ||
type == XML_READER_TYPE_TEXT ||
type == XML_READER_TYPE_COMMENT)
{
/* eat it */
}
else
{
/* ignore it */
}
ret = xmlTextReaderRead (reader);
}
xmlFreeTextReader (reader);
out:
if (ret < 0 || state != STATE_STOP)
{
/* This is not critical, we will fallback to our own code */
g_free (filename);
return FALSE;
}
GMappedFile *mapped_file;
gchar *filename;
GError *error = NULL;
filename = g_build_filename (ISO_CODES_PREFIX, "share", "xml", "iso-codes",
basename, NULL);
mapped_file = g_mapped_file_new (filename, FALSE, &error);
g_free (filename);
return TRUE;
if (mapped_file != NULL)
{
GMarkupParseContext *context;
const gchar *contents;
gsize length;
context = g_markup_parse_context_new (parser, 0, hash_table, NULL);
contents = g_mapped_file_get_contents (mapped_file);
length = g_mapped_file_get_length (mapped_file);
g_markup_parse_context_parse (context, contents, length, &error);
g_markup_parse_context_free (context);
g_mapped_file_unref (mapped_file);
}
if (error != NULL)
{
g_warning ("%s: %s", basename, error->message);
g_error_free (error);
}
}
#endif /* HAVE_ISO_CODES */
static void
ensure_iso_codes_initialised (void)
/**
* codetable_init:
*
* Initializes the code table.
*/
void
codetable_init (void)
{
static gboolean initialised = FALSE;
GMarkupParser iso_639_parser = {
iso_639_start_element, NULL, NULL, NULL, NULL
};
if (initialised == TRUE)
{
return;
}
initialised = TRUE;
GMarkupParser iso_3166_parser = {
iso_3166_start_element, NULL, NULL, NULL, NULL
};
#if defined (ENABLE_NLS) && defined (HAVE_ISO_CODES)
bindtextdomain (ISO_639_DOMAIN, ISOCODESLOCALEDIR);
g_return_if_fail (iso_639_table == NULL);
g_return_if_fail (iso_3166_table == NULL);
#ifdef ENABLE_NLS
bindtextdomain (ISO_639_DOMAIN, ISO_CODES_LOCALEDIR);
bind_textdomain_codeset (ISO_639_DOMAIN, "UTF-8");
bindtextdomain(ISO_3166_DOMAIN, ISOCODESLOCALEDIR);
bindtextdomain (ISO_3166_DOMAIN, ISO_CODES_LOCALEDIR);
bind_textdomain_codeset (ISO_3166_DOMAIN, "UTF-8");
#endif
iso_639_table = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify) xmlFree,
(GDestroyNotify) xmlFree);
(GDestroyNotify)g_free, (GDestroyNotify)g_free);
iso_3166_table = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify) g_free,
(GDestroyNotify) xmlFree);
#ifdef HAVE_ISO_CODES
load_iso_entries (639, (GFunc) read_iso_639_entry, iso_639_table);
load_iso_entries (3166, (GFunc) read_iso_3166_entry, iso_3166_table);
#endif
}
(GDestroyNotify)g_free, (GDestroyNotify)g_free);
static char *
get_iso_name_for_lang_code (const char *code)
{
char **str;
char *name = NULL;
const char *langname, *localename;
int len;
str = g_strsplit (code, "_", -1);
/* count the entries */
for (len = 0; str[len]; len++ ) /* empty */;
g_return_val_if_fail (len != 0, NULL);
langname = (const char *) g_hash_table_lookup (iso_639_table, str[0]);
if (len == 1 && langname != NULL)
{
name = g_strdup (dgettext (ISO_639_DOMAIN, langname));
}
else if (len == 2 && langname != NULL)
{
localename = (const char *) g_hash_table_lookup (iso_3166_table, str[1]);
if (localename != NULL)
{
/* translators: the first %s is the language name, and the
* second %s is the locale name. Example:
* "French (France)
*
* Also: The text before the "|" is context to help you decide on
* the correct translation. You MUST OMIT it in the translated string.
*/
name = g_strdup_printf (Q_("language|%s (%s)"),
dgettext (ISO_639_DOMAIN, langname),
dgettext (ISO_3166_DOMAIN, localename));
}
else
{
name = g_strdup_printf (Q_("language|%s (%s)"),
dgettext (ISO_639_DOMAIN, langname), str[1]);
}
}
g_strfreev (str);
return name;
iso_codes_parse (&iso_639_parser, "iso_639.xml", iso_639_table);
iso_codes_parse (&iso_3166_parser, "iso_3166.xml", iso_3166_table);
}
/**
* gtkspell_iso_codes_lookup_name_for_code:
* @code: A language code, e.g. en_CA
*
* Looks up a name to display to the user for a language code,
* this might use the iso-codes package if support was compiled
* in, and it is available
*
* Returns: the UTF-8 string to display to the user, or NULL if
* a name for the code could not be found
*/
char *
gtkspell_iso_codes_lookup_name_for_code (const char *code)
* codetable_free:
*
* Frees the code table.
*/
void
codetable_free (void)
{
char * lcode;
char * ret;
g_return_if_fail (iso_639_table != NULL);
g_return_if_fail (iso_3166_table != NULL);
g_return_val_if_fail (code != NULL, NULL);
g_hash_table_unref (iso_639_table);
g_hash_table_unref (iso_3166_table);
ensure_iso_codes_initialised ();
lcode = g_ascii_strdown (code, -1);
ret = get_iso_name_for_lang_code (lcode);
g_free (lcode);
return ret;
iso_639_table = NULL;
iso_3166_table = NULL;
}
/**
* codetable_lookup:
* @language_code: A language code (i.e. "en_US")
* @language_name: (out) (transfer none): Pointer to the name of the language.
* This pointer is owned by the code table and must not be freed.
* @country_name: (out) (transfer none): Pointer to the name of the country.
* This pointer is owned by the code table and must not be freed.
*
* Looks up the language and country name for the specified language code.
* If no matching entries are found, language_name and country_name will
* simply contain the parts of the language code (i.e. "en" and "US").
*/
void
codetable_lookup (const gchar *language_code, const gchar **language_name, const gchar** country_name)
{
gchar **parts;
g_return_if_fail (iso_639_table != NULL);
g_return_if_fail (iso_3166_table != NULL);
/* Split language code into parts. */
parts = g_strsplit (language_code, "_", 2);
g_return_if_fail (*parts != NULL);
*language_name = g_hash_table_lookup (iso_639_table, parts[0]);
if (*language_name == NULL)
{
g_hash_table_insert (iso_639_table, g_strdup (parts[0]),
g_strdup (parts[0]));
*language_name = g_hash_table_lookup (iso_639_table, parts[0]);
}
if (g_strv_length (parts) == 2)
{
*country_name = g_hash_table_lookup (iso_3166_table, parts[1]);
if (*country_name == NULL)
{
g_hash_table_insert (iso_3166_table, g_strdup (parts[1]),
g_strdup (parts[1]));
*country_name = g_hash_table_lookup (iso_3166_table, parts[1]);
}
}
g_strfreev (parts);
}

View File

@ -1,35 +1,37 @@
/*
* Copyright (C) 2005 Nathan Fredrickson
* Borrowed from Galeon, renamed, and simplified to only use iso-codes with no
* fallback method.
*
* Copyright (C) 2004 Christian Persch
* Copyright (C) 2004 Crispin Flowerday
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
/* gtkspell - a spell-checking addon for GTK's TextView widget
* Copyright (c) 2013 Sandro Mani
*
* Based on gtkhtml-editor-spell-language.c code which is
* Copyright (C) 2008 Novell, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef GTKSPELL_ISO_CODES_H
#define GTKSPELL_ISO_CODES_H
#ifndef GTK_SPELL_CODETABLE_H
#define GTK_SPELL_CODETABLE_H
#include <glib.h>
G_BEGIN_DECLS
char * gtkspell_iso_codes_lookup_name_for_code (const char *code);
void codetable_init (void);
void codetable_free (void);
void codetable_lookup (const gchar *language_code,
const gchar **language_name,
const gchar **country_name);
G_END_DECLS
#endif
#endif /* GTK_SPELL_CODETABLE_H */

View File

@ -577,11 +577,14 @@ build_spelling_menu(SexySpellEntry *entry, const gchar *word)
for (li = entry->priv->dict_list; li; li = g_slist_next (li)) {
dict = (struct EnchantDict *) li->data;
lang = get_lang_from_dict(dict);
lang_name = gtkspell_iso_codes_lookup_name_for_code(lang);
if (lang_name) {
lang_name = sexy_spell_entry_get_language_name (entry, lang);
if (lang_name)
{
mi = gtk_menu_item_new_with_label(lang_name);
g_free(lang_name);
} else {
g_free (lang_name);
}
else
{
mi = gtk_menu_item_new_with_label(lang);
}
g_free(lang);
@ -621,11 +624,14 @@ build_spelling_menu(SexySpellEntry *entry, const gchar *word)
for (li = entry->priv->dict_list; li; li = g_slist_next(li)) {
dict = (struct EnchantDict *)li->data;
lang = get_lang_from_dict(dict);
lang_name = gtkspell_iso_codes_lookup_name_for_code(lang);
if (lang_name) {
lang_name = sexy_spell_entry_get_language_name (entry, lang);
if (lang_name)
{
submi = gtk_menu_item_new_with_label(lang_name);
g_free(lang_name);
} else {
g_free (lang_name);
}
else
{
submi = gtk_menu_item_new_with_label(lang);
}
g_free(lang);
@ -699,6 +705,10 @@ sexy_spell_entry_init(SexySpellEntry *entry)
if (have_enchant)
sexy_spell_entry_activate_default_languages(entry);
#ifdef HAVE_ISO_CODES
codetable_init ();
#endif
entry->priv->attr_list = pango_attr_list_new();
entry->priv->checked = TRUE;
@ -743,6 +753,9 @@ sexy_spell_entry_finalize(GObject *obj)
}
g_free(entry->priv);
#ifdef HAVE_ISO_CODES
codetable_free ();
#endif
if (G_OBJECT_CLASS(parent_class)->finalize)
G_OBJECT_CLASS(parent_class)->finalize(obj);
@ -1273,9 +1286,21 @@ gchar *
sexy_spell_entry_get_language_name(const SexySpellEntry *entry,
const gchar *lang)
{
if (have_enchant)
return gtkspell_iso_codes_lookup_name_for_code(lang);
return NULL;
#ifdef HAVE_ISO_CODES
const gchar *lang_name = "";
const gchar *country_name = "";
g_return_val_if_fail (have_enchant, NULL);
codetable_lookup (lang, &lang_name, &country_name);
if (strlen (country_name) != 0)
return g_strdup_printf ("%s (%s)", lang_name, country_name);
else
return g_strdup_printf ("%s", lang_name);
#else
return g_strdup (lang);
#endif
}
/**