Revision: 256 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=256&view=rev Author: eht16 Date: 2008-10-29 18:48:17 +0000 (Wed, 29 Oct 2008)
Log Message: ----------- Improve the auto-detection of the user's language (handle locales like 'de_DE.UTF-8' correctly).
Modified Paths: -------------- trunk/spellcheck/ChangeLog trunk/spellcheck/src/scplugin.c trunk/spellcheck/src/speller.c trunk/spellcheck/src/speller.h
Modified: trunk/spellcheck/ChangeLog =================================================================== --- trunk/spellcheck/ChangeLog 2008-10-26 14:37:23 UTC (rev 255) +++ trunk/spellcheck/ChangeLog 2008-10-29 18:48:17 UTC (rev 256) @@ -1,3 +1,10 @@ +2008-10-29 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de> + + * src/speller.c, src/speller.h, src/scplugin.c: + Improve the auto-detection of the user's language (handle locales + like 'de_DE.UTF-8' correctly). + + 2008-10-25 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* src/speller.c:
Modified: trunk/spellcheck/src/scplugin.c =================================================================== --- trunk/spellcheck/src/scplugin.c 2008-10-26 14:37:23 UTC (rev 255) +++ trunk/spellcheck/src/scplugin.c 2008-10-29 18:48:17 UTC (rev 256) @@ -184,7 +184,9 @@ GtkWidget *sp_item; GKeyFile *config = g_key_file_new(); guint i; + gchar *default_lang;
+ default_lang = speller_get_default_lang(); sc = g_new0(SpellCheck, 1);
sc->config_file = g_strconcat(geany->app->configdir, G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S, @@ -192,13 +194,14 @@
g_key_file_load_from_file(config, sc->config_file, G_KEY_FILE_NONE, NULL); sc->default_language = p_utils->get_setting_string(config, - "spellcheck", "language", speller_get_default_lang()); + "spellcheck", "language", default_lang); sc->check_while_typing = p_utils->get_setting_boolean(config, "spellcheck", "check_while_typing", FALSE); sc->show_toolbar_item = p_utils->get_setting_boolean(config, "spellcheck", "show_toolbar_item", TRUE); sc->use_msgwin = p_utils->get_setting_boolean(config, "spellcheck", "use_msgwin", FALSE); g_key_file_free(config); + g_free(default_lang);
locale_init();
Modified: trunk/spellcheck/src/speller.c =================================================================== --- trunk/spellcheck/src/speller.c 2008-10-26 14:37:23 UTC (rev 255) +++ trunk/spellcheck/src/speller.c 2008-10-29 18:48:17 UTC (rev 256) @@ -269,18 +269,26 @@ }
-const gchar *speller_get_default_lang(void) +gchar *speller_get_default_lang(void) { const gchar *lang = g_getenv("LANG"); + gchar *result = NULL; + if (NZV(lang)) { - if (g_ascii_strncasecmp(lang, "C", 1) == 0) + if (*lang == 'C' || *lang == 'c') lang = "en"; + else + { /* if we have something like de_DE.UTF-8, strip everything from the period to the end */ + gchar *period = strchr(lang, '.'); + if (period != NULL) + result = g_strndup(lang, g_utf8_pointer_to_offset(lang, period)); + } } else lang = "en";
- return lang; + return (result != NULL) ? result : g_strdup(lang); }
Modified: trunk/spellcheck/src/speller.h =================================================================== --- trunk/spellcheck/src/speller.h 2008-10-26 14:37:23 UTC (rev 255) +++ trunk/spellcheck/src/speller.h 2008-10-29 18:48:17 UTC (rev 256) @@ -33,7 +33,7 @@
void speller_reinit_enchant_dict(void);
-const gchar *speller_get_default_lang(void); +gchar *speller_get_default_lang(void);
void speller_dict_free_string_list(gchar **tmp_suggs);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
plugins-commits@lists.geany.org