summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEduard Braun <eduard.braun2@gmx.de>2017-05-07 20:50:07 +0000
committerEduard Braun <eduard.braun2@gmx.de>2017-05-07 20:50:07 +0000
commit6e0b1cc358cadb3bfefceb39acf613ac7450b978 (patch)
treea1cd65411364d7d88323d7e1634d25020829af8e /src
parentUse glib to get the installation prefix on Windows (diff)
downloadinkscape-6e0b1cc358cadb3bfefceb39acf613ac7450b978.tar.gz
inkscape-6e0b1cc358cadb3bfefceb39acf613ac7450b978.zip
Move gettext initialization into separate function so it can be re-used (will come in handy in inkview)
(bzr r15675.1.2)
Diffstat (limited to 'src')
-rw-r--r--src/helper/CMakeLists.txt6
-rw-r--r--src/helper/gettext.cpp83
-rw-r--r--src/helper/gettext.h44
-rw-r--r--src/main.cpp38
4 files changed, 136 insertions, 35 deletions
diff --git a/src/helper/CMakeLists.txt b/src/helper/CMakeLists.txt
index 92709e4e9..443648c5c 100644
--- a/src/helper/CMakeLists.txt
+++ b/src/helper/CMakeLists.txt
@@ -10,12 +10,13 @@ set(sp_marshal_SRC
set(helper_SRC
action.cpp
- action-context.cpp
+ action-context.cpp
geom.cpp
geom-nodetype.cpp
geom-pathstroke.cpp
geom-pathvectorsatellites.cpp
geom-satellite.cpp
+ gettext.cpp
gnome-utils.cpp
pixbuf-ops.cpp
png-write.cpp
@@ -30,13 +31,14 @@ set(helper_SRC
# -------
# Headers
action.h
- action-context.h
+ action-context.h
geom-curves.h
geom-nodetype.h
geom-pathstroke.h
geom-pathvectorsatellites.h
geom-satellite.h
geom.h
+ gettext.h
gnome-utils.h
mathfns.h
pixbuf-ops.h
diff --git a/src/helper/gettext.cpp b/src/helper/gettext.cpp
new file mode 100644
index 000000000..4fa8df7ae
--- /dev/null
+++ b/src/helper/gettext.cpp
@@ -0,0 +1,83 @@
+/**
+ * \file
+ * \brief helper functions for gettext
+ *//*
+ * Authors:
+ * Eduard Braun <eduard.braun2@gmx.de>
+ *
+ * Copyright 2017 Authors
+ *
+ * This file is part of Inkscape.
+ *
+ * Inkscape 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Inkscape 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 Inkscape. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <glib.h>
+#include <glib/gi18n.h>
+
+namespace Inkscape {
+
+void initialize_gettext() {
+#ifdef WIN32
+ gchar *datadir = g_win32_get_package_installation_directory_of_module(NULL);
+
+ // 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);
+
+ g_free(datadir);
+
+#else
+# 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);
+}
+
+}
+
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace .0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim:filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99: \ No newline at end of file
diff --git a/src/helper/gettext.h b/src/helper/gettext.h
new file mode 100644
index 000000000..2a072b9e0
--- /dev/null
+++ b/src/helper/gettext.h
@@ -0,0 +1,44 @@
+/**
+ * \file
+ * \brief helper functions for gettext
+ *//*
+ * Authors:
+ * Eduard Braun <eduard.braun2@gmx.de>
+ *
+ * Copyright 2017 Authors
+ *
+ * This file is part of Inkscape.
+ *
+ * Inkscape 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Inkscape 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 Inkscape. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef SEEN_GETTEXT_HELPER_H
+#define SEEN_GETTEXT_HELPER_H
+
+namespace Inkscape {
+ void initialize_gettext();
+}
+
+#endif // SEEN_GETTEXT_HELPER_H
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace .0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim:filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99: \ No newline at end of file
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 <extension/extension.h>
@@ -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)