From fb85d5e1be440be7e9ee75e1a41d49e37383688c Mon Sep 17 00:00:00 2001 From: Patrick Storz Date: Sun, 10 Mar 2019 01:19:40 +0100 Subject: Save default template as "default.$lang.svg" if present By default we want to save as "default.svg", so it works indepentent from the UI language selected. However if a localized default template like "default.de.svg" is already present (i.e. manually created by the user), it will override our custom template, so we need to overwrite it. Second part of a fix for https://gitlab.com/inkscape/inkscape/issues/103 --- src/file.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp index cb672e690..b23ed2185 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1008,8 +1008,7 @@ sp_file_save_template(Gtk::Window &parentWindow, Glib::ustring name, auto encodedName = Glib::uri_escape_string(name); encodedName.append(".svg"); - auto filename = Inkscape::IO::Resource::get_path_ustring(USER, TEMPLATES, - encodedName.c_str()); + auto filename = Inkscape::IO::Resource::get_path_ustring(USER, TEMPLATES, encodedName.c_str()); auto operation_confirmed = sp_ui_overwrite_file(filename.c_str()); @@ -1020,9 +1019,14 @@ sp_file_save_template(Gtk::Window &parentWindow, Glib::ustring name, Inkscape::Extension::FILE_SAVE_METHOD_INKSCAPE_SVG); if (isDefault) { + // save as "default.svg" by default (so it works intependent of UI language)unless + // a localized template like "default.de.svg" is already present (which overrides "default.svg") + Glib::ustring default_svg_localized = Glib::ustring("default.") + _("en") + ".svg"; + filename = Inkscape::IO::Resource::get_path_ustring(USER, TEMPLATES, default_svg_localized.c_str()); - filename = Inkscape::IO::Resource::get_path_ustring(USER, - TEMPLATES, "default.svg"); + if (!Inkscape::IO::file_test(filename.c_str(), G_FILE_TEST_EXISTS)) { + filename = Inkscape::IO::Resource::get_path_ustring(USER, TEMPLATES, "default.svg"); + } file_save(parentWindow, document, filename, Inkscape::Extension::db.get(".svg"), false, false, -- cgit v1.2.3