Use setlocale to enable translation of strings before GLib command line parser gets active.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1640 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Enrico Tröger 2007-06-25 17:49:45 +00:00
parent 8a3eb871ce
commit 22c3dd033b
2 changed files with 20 additions and 5 deletions

View File

@ -1,3 +1,9 @@
2007-06-25 Enrico Tröger <enrico.troeger@uvena.de>
* src/main.c: Use setlocale to enable translation of strings before
GLib command line parser gets active.
2007-06-24 Enrico Tröger <enrico.troeger@uvena.de> 2007-06-24 Enrico Tröger <enrico.troeger@uvena.de>
* geany.nsi: Fix wrong working directory in generated shortcuts. * geany.nsi: Fix wrong working directory in generated shortcuts.

View File

@ -35,6 +35,10 @@
#include "geany.h" #include "geany.h"
#if HAVE_LOCALE_H
# include <locale.h>
#endif
#include "main.h" #include "main.h"
#include "interface.h" #include "interface.h"
#include "support.h" #include "support.h"
@ -69,8 +73,9 @@
# include "vte.h" # include "vte.h"
#endif #endif
#define N_(String) (String) #ifndef N_
# define N_(String) (String)
#endif
CommandLineOptions cl_options; // fields initialised in parse_command_line_options CommandLineOptions cl_options; // fields initialised in parse_command_line_options
@ -405,8 +410,13 @@ static void setup_paths()
static void locale_init() static void locale_init()
{ {
#ifdef ENABLE_NLS
gchar *locale_dir = NULL; gchar *locale_dir = NULL;
#if HAVE_LOCALE_H
setlocale(LC_ALL, "");
#endif
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
gchar *install_dir = g_win32_get_package_installation_directory("geany", NULL); gchar *install_dir = g_win32_get_package_installation_directory("geany", NULL);
// e.g. C:\Program Files\geany\lib\locale // e.g. C:\Program Files\geany\lib\locale
@ -416,12 +426,11 @@ static void locale_init()
locale_dir = g_strdup(PACKAGE_LOCALE_DIR); locale_dir = g_strdup(PACKAGE_LOCALE_DIR);
#endif #endif
#ifdef ENABLE_NLS
bindtextdomain(GETTEXT_PACKAGE, locale_dir); bindtextdomain(GETTEXT_PACKAGE, locale_dir);
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
textdomain(GETTEXT_PACKAGE); textdomain(GETTEXT_PACKAGE);
#endif
g_free(locale_dir); g_free(locale_dir);
#endif
} }
@ -435,7 +444,7 @@ static void parse_command_line_options(gint *argc, gchar ***argv)
cl_options.goto_line = -1; cl_options.goto_line = -1;
cl_options.goto_column = -1; cl_options.goto_column = -1;
context = g_option_context_new(_(" - A fast and lightweight IDE")); context = g_option_context_new(_("[FILES...]"));
g_option_context_add_main_entries(context, entries, GETTEXT_PACKAGE); g_option_context_add_main_entries(context, entries, GETTEXT_PACKAGE);
g_option_group_set_translation_domain(g_option_context_get_main_group(context), GETTEXT_PACKAGE); g_option_group_set_translation_domain(g_option_context_get_main_group(context), GETTEXT_PACKAGE);
g_option_context_add_group(context, gtk_get_option_group(TRUE)); g_option_context_add_group(context, gtk_get_option_group(TRUE));