From 0d59c73ce3f5b569df6037436654c24f19c5e537 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sun, 7 May 2017 21:11:29 +0200 Subject: Use glib to get the installation prefix on Windows (bzr r15675.1.1) --- src/main.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 3a7050f9b..c4fcb6589 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -680,19 +680,19 @@ main(int argc, char **argv) #endif #ifdef WIN32 - gchar *exedir = g_strdup(win32_getExePath().data()); - _win32_set_inkscape_env(exedir); + gchar *datadir = g_win32_get_package_installation_directory_of_module(NULL); + _win32_set_inkscape_env(datadir); # ifdef ENABLE_NLS // obtain short path to executable dir and pass it // to bindtextdomain (it doesn't understand UTF-8) - gchar *shortexedir = g_win32_locale_filename_from_utf8(exedir); - gchar *localepath = g_build_filename(shortexedir, PACKAGE_LOCALE_DIR, NULL); + gchar *shortdatadir = g_win32_locale_filename_from_utf8(datadir); + gchar *localepath = g_build_filename(shortdatadir, PACKAGE_LOCALE_DIR, NULL); bindtextdomain(GETTEXT_PACKAGE, localepath); - g_free(shortexedir); + g_free(shortdatadir); g_free(localepath); # endif - g_free(exedir); + g_free(datadir); // Don't touch the registry (works fine without it) for Inkscape Portable gchar const *val = g_getenv("INKSCAPE_PORTABLE_PROFILE_DIR"); -- cgit v1.2.3 From 6e0b1cc358cadb3bfefceb39acf613ac7450b978 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sun, 7 May 2017 22:50:07 +0200 Subject: Move gettext initialization into separate function so it can be re-used (will come in handy in inkview) (bzr r15675.1.2) --- src/main.cpp | 38 +++++--------------------------------- 1 file changed, 5 insertions(+), 33 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index c4fcb6589..02562383a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -80,6 +80,7 @@ #include "debug/log-display-config.h" #include "helper/action-context.h" +#include "helper/gettext.h" #include "helper/png-write.h" #include @@ -679,19 +680,13 @@ main(int argc, char **argv) fpsetmask(fpgetmask() & ~(FP_X_DZ | FP_X_INV)); #endif +#ifdef ENABLE_NLS + Inkscape::initialize_gettext(); +#endif + #ifdef WIN32 gchar *datadir = g_win32_get_package_installation_directory_of_module(NULL); _win32_set_inkscape_env(datadir); - -# ifdef ENABLE_NLS - // obtain short path to executable dir and pass it - // to bindtextdomain (it doesn't understand UTF-8) - gchar *shortdatadir = g_win32_locale_filename_from_utf8(datadir); - gchar *localepath = g_build_filename(shortdatadir, PACKAGE_LOCALE_DIR, NULL); - bindtextdomain(GETTEXT_PACKAGE, localepath); - g_free(shortdatadir); - g_free(localepath); -# endif g_free(datadir); // Don't touch the registry (works fine without it) for Inkscape Portable @@ -705,29 +700,6 @@ main(int argc, char **argv) // see also https://bugzilla.gnome.org/show_bug.cgi?id=778791 g_setenv("GTK_CSD", "0", FALSE); #endif - -#ifdef ENABLE_NLS -# ifndef WIN32 -# ifdef ENABLE_BINRELOC - bindtextdomain(GETTEXT_PACKAGE, BR_LOCALEDIR("")); -# else - bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); - // needed by Python/Gettext - g_setenv("PACKAGE_LOCALE_DIR", PACKAGE_LOCALE_DIR, TRUE); -# endif -# endif - // Allow the user to override the locale directory by setting - // the environment variable INKSCAPE_LOCALEDIR. - char const *inkscape_localedir = g_getenv("INKSCAPE_LOCALEDIR"); - if (inkscape_localedir != NULL) { - bindtextdomain(GETTEXT_PACKAGE, inkscape_localedir); - } - - // common setup - bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); - textdomain(GETTEXT_PACKAGE); -#endif - set_extensions_env(); // Prevents errors like "Unable to wrap GdkPixbuf..." (in nr-filter-image.cpp for example) -- cgit v1.2.3 From c91214d837562c6244053dfeaf99aa2d8b8deded Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Mon, 8 May 2017 00:11:49 +0200 Subject: Move functions for switching gettext charset to helper/gettext.h (bzr r15675.1.3) --- src/main.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 02562383a..b2817fa97 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -857,10 +857,7 @@ static int sp_common_main( int argc, char const **argv, GSList **flDest ) // temporarily switch gettext encoding to locale, so that help messages can be output properly - std::string charset; - Glib::get_charset(charset); - - bind_textdomain_codeset(GETTEXT_PACKAGE, charset.c_str()); + Inkscape::bind_textdomain_codeset_console(); poptContext ctx = poptGetContext(NULL, argc, argv, options, 0); poptSetOtherOptionHelp(ctx, _("[OPTIONS...] [FILE...]\n\nAvailable options:")); @@ -871,7 +868,7 @@ static int sp_common_main( int argc, char const **argv, GSList **flDest ) poptFreeContext(ctx); // now switch gettext back to UTF-8 (for GUI) - bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); + Inkscape::bind_textdomain_codeset_utf8(); // Now let's see if the file list still holds up if ( needToRecodeParams ) -- cgit v1.2.3 From f5ab987943d3d54291dfe9369b7cb9855ddb7d8f Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Mon, 8 May 2017 00:14:37 +0200 Subject: Properly handle ENABLE_NLS define (bzr r15675.1.4) --- src/main.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index b2817fa97..4c63402fb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -80,8 +80,10 @@ #include "debug/log-display-config.h" #include "helper/action-context.h" -#include "helper/gettext.h" #include "helper/png-write.h" +#ifdef ENABLE_NLS +#include "helper/gettext.h" +#endif #include #include @@ -108,10 +110,6 @@ #include #include -#ifndef HAVE_BIND_TEXTDOMAIN_CODESET -#define bind_textdomain_codeset(p,c) -#endif - #include "main-cmdlineact.h" #include "main-cmdlinexact.h" #include "widgets/icon.h" @@ -851,13 +849,10 @@ static GSList *fixupFilenameEncoding( GSList* fl ) static int sp_common_main( int argc, char const **argv, GSList **flDest ) { - /// \todo fixme: Move these to some centralized location (Lauris) - //sp_object_type_register("sodipodi:namedview", SP_TYPE_NAMEDVIEW); - //sp_object_type_register("sodipodi:guide", SP_TYPE_GUIDE); - - +#ifdef ENABLE_NLS // temporarily switch gettext encoding to locale, so that help messages can be output properly Inkscape::bind_textdomain_codeset_console(); +#endif poptContext ctx = poptGetContext(NULL, argc, argv, options, 0); poptSetOtherOptionHelp(ctx, _("[OPTIONS...] [FILE...]\n\nAvailable options:")); @@ -866,9 +861,11 @@ static int sp_common_main( int argc, char const **argv, GSList **flDest ) /* Collect own arguments */ GSList *fl = sp_process_args(ctx); poptFreeContext(ctx); - + +#ifdef ENABLE_NLS // now switch gettext back to UTF-8 (for GUI) Inkscape::bind_textdomain_codeset_utf8(); +#endif // Now let's see if the file list still holds up if ( needToRecodeParams ) -- cgit v1.2.3