summaryrefslogtreecommitdiffstats
path: root/src/help.cpp
diff options
context:
space:
mode:
authorPatrick Storz <eduard.braun2@gmx.de>2019-02-16 22:44:21 +0000
committerPatrick Storz <eduard.braun2@gmx.de>2019-02-16 22:44:21 +0000
commit48d75545fec31f7121cdd0073e2ce7a1de2d9ca0 (patch)
treec36a293c23831d2d84ac6d2c03a2a00b5c3767d9 /src/help.cpp
parentShow helpful message if tutorials are not installed (diff)
downloadinkscape-48d75545fec31f7121cdd0073e2ce7a1de2d9ca0.tar.gz
inkscape-48d75545fec31f7121cdd0073e2ce7a1de2d9ca0.zip
Tutorials: Improve logic for loading localized versions
There's no need to translate every filename, just translate the language code. Also use Inkscape::IO::Resource::get_filename to ensure we fall-back to Englishstutorials should the localized versions not be available.
Diffstat (limited to 'src/help.cpp')
-rw-r--r--src/help.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/help.cpp b/src/help.cpp
index 3c76797c0..fd935e8c2 100644
--- a/src/help.cpp
+++ b/src/help.cpp
@@ -17,28 +17,36 @@
#include "file.h"
#include "help.h"
+#include "io/resource.h"
#include "io/sys.h"
#include "path-prefix.h"
#include "ui/dialog/aboutbox.h"
#include "ui/interface.h"
+
+using namespace Inkscape::IO::Resource;
+
+
void sp_help_about()
{
Inkscape::UI::Dialog::AboutBox::show_about();
}
-void sp_help_open_tutorial(GtkMenuItem *, void* data)
+void sp_help_open_tutorial(Glib::ustring name)
{
- gchar const *name = static_cast<gchar const *>(data);
- gchar *c = g_build_filename(INKSCAPE_TUTORIALSDIR, name, NULL);
- if (Inkscape::IO::file_test(c, G_FILE_TEST_EXISTS)) {
- sp_file_open(c, nullptr, false, false);
+ Glib::ustring filename = name + ".svg";
+ // TRANSLATORS: 'en' is a ISO 639-1 language code.
+ // Replace with language code for your language (i.e. the name of your .po file)
+ Glib::ustring filename_localized = name + "." + _("en") + ".svg";
+
+ filename = get_filename(TUTORIALS, filename.c_str(), filename_localized.c_str());
+ if (!filename.empty()) {
+ sp_file_open(filename.c_str(), nullptr, false, false);
} else {
sp_ui_error_dialog(_("The tutorial files are not installed.\nFor Linux, you may need to install "
"'inkscape-tutorials'; for Windows, please re-run the setup and select 'Tutorials'.\nThe "
"tutorials can also be found online at https://inkscape.org/learn/tutorials/"));
}
- g_free(c);
}
/*