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/helper/gettext.cpp | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'src/helper/gettext.cpp') diff --git a/src/helper/gettext.cpp b/src/helper/gettext.cpp index 4fa8df7ae..0972d4e19 100644 --- a/src/helper/gettext.cpp +++ b/src/helper/gettext.cpp @@ -27,11 +27,17 @@ # include "config.h" #endif -#include -#include +#ifdef WIN32 +#include +#endif + +#include +#include +#include namespace Inkscape { +/** does all required gettext initialization and takes care of the respective locale directory paths */ void initialize_gettext() { #ifdef WIN32 gchar *datadir = g_win32_get_package_installation_directory_of_module(NULL); @@ -67,6 +73,26 @@ void initialize_gettext() { bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); } + +/** set gettext codeset to UTF8 */ +void bind_textdomain_codeset_utf8() { + bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); +} + +/** set gettext codeset to codeset of the console + * - on *nix this is typically the current locale, + * - on Windows it has to be determined using GetConsoleOutputCP() */ +void bind_textdomain_codeset_console() { + std::string charset; + Glib::get_charset(charset); + + // TODO: does not work properly as we spawn a child process on Windows + // (inkscape.exe is not a console application and can never print directly to console) + //unsigned int test = GetConsoleOutputCP(); + //g_message("CP%u", test); + + bind_textdomain_codeset(GETTEXT_PACKAGE, charset.c_str()); +} } -- cgit v1.2.3