From ecd36f0dc901a3dc538df68c75f3e0a3f591a37e Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Fri, 12 May 2017 04:06:58 +0200 Subject: Inkview: Fix gettext localization (bzr r15687.1.1) --- src/inkview.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/inkview.cpp') diff --git a/src/inkview.cpp b/src/inkview.cpp index a7a6b6a78..abb12462a 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -223,22 +223,22 @@ class InkviewOptionsGroup : public Glib::OptionGroup public: InkviewOptionsGroup() : - Glib::OptionGroup(_("Inkscape Options"), - _("Default program options")), + Glib::OptionGroup(N_("Inkscape Options"), + N_("Default program options")), _entry_timer(), _entry_args() { // Entry for the "timer" option _entry_timer.set_short_name('t'); _entry_timer.set_long_name("timer"); - _entry_timer.set_arg_description(_("NUM")); - _entry_timer.set_description(_("Reset timer:")); + _entry_timer.set_arg_description(N_("NUM")); + _entry_timer.set_description(N_("Reset timer:")); add_entry(_entry_timer, timer); // Entry for the remaining non-option arguments _entry_args.set_short_name('\0'); _entry_args.set_long_name(G_OPTION_REMAINING); - _entry_args.set_arg_description(_("FILES...")); + _entry_args.set_arg_description(N_("FILES...")); add_entry(_entry_args, filenames); } @@ -254,8 +254,12 @@ int main (int argc, char **argv) Inkscape::initialize_gettext(); #endif - Glib::OptionContext opt(_("Open SVG files")); + Glib::OptionContext opt(N_("Open SVG files")); + opt.set_translation_domain(GETTEXT_PACKAGE); + InkviewOptionsGroup grp; + grp.set_translation_domain(GETTEXT_PACKAGE); + opt.set_main_group(grp); // Prevents errors like "Unable to wrap GdkPixbuf..." (in nr-filter-image.cpp for example) -- cgit v1.2.3 From 30c69ed93c47ef06a7a777bda2b02e6b7c25eedc Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Fri, 12 May 2017 04:18:06 +0200 Subject: Inkview: Fix encoding of console output on Windows To do this we have to "hack" g_print() as the glib people decided Windows consoles should be limited to 255 character code pages forevermore and g_print() converts all strings to the system's ANSI code page without exception. (see http://stackoverflow.com/q/43927373/2514664 for details) (bzr r15687.1.2) --- src/inkview.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/inkview.cpp') diff --git a/src/inkview.cpp b/src/inkview.cpp index abb12462a..cbbd4d6c3 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -248,8 +248,22 @@ private: Glib::OptionEntry _entry_args; }; + +#ifdef WIN32 +// minimal print handler (just prints the string to stdout) +void g_print_no_convert(const gchar *buf) +{ + fputs(buf, stdout); +} +#endif + int main (int argc, char **argv) { +#ifdef WIN32 + // Ugly hack to make g_print emit UTF-8 encoded characters. Otherwise glib will *always* + // perform character conversion to the system's ANSI code page making UTF-8 output impossible. + g_set_print_handler(g_print_no_convert); +#endif #ifdef ENABLE_NLS Inkscape::initialize_gettext(); #endif @@ -275,7 +289,7 @@ int main (int argc, char **argv) if(filenames.empty()) { - std::cout << opt.get_help(); + g_print(opt.get_help().c_str()); exit(EXIT_FAILURE); } -- cgit v1.2.3 From a560e28ed15c14afd9a4657ce4a33895eeed0397 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Fri, 12 May 2017 04:27:13 +0200 Subject: Inkview: minor cleanup (bzr r15687.1.3) --- src/inkview.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'src/inkview.cpp') diff --git a/src/inkview.cpp b/src/inkview.cpp index cbbd4d6c3..ca3d16cdf 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -144,12 +144,6 @@ SPSlideShow::SPSlideShow(std::vector const &slides) show(); } -static void usage(); - - -// Dummy functions to keep linker happy -int sp_main_gui (int, char const**) { return 0; } -int sp_main_console (int, char const**) { return 0; } static int sp_svgview_main_delete (GtkWidget */*widget*/, GdkEvent */*event*/, @@ -238,7 +232,7 @@ public: // Entry for the remaining non-option arguments _entry_args.set_short_name('\0'); _entry_args.set_long_name(G_OPTION_REMAINING); - _entry_args.set_arg_description(N_("FILES...")); + _entry_args.set_arg_description(N_("FILES …")); add_entry(_entry_args, filenames); } @@ -276,8 +270,6 @@ int main (int argc, char **argv) opt.set_main_group(grp); - // Prevents errors like "Unable to wrap GdkPixbuf..." (in nr-filter-image.cpp for example) - Gtk::Main::init_gtkmm_internals(); Gtk::Main main_instance (argc, argv, opt); LIBXML_TEST_VERSION -- cgit v1.2.3