diff --git a/openscad.pro b/openscad.pro index 5d36d0d9..d16da5d3 100644 --- a/openscad.pro +++ b/openscad.pro @@ -8,7 +8,12 @@ # OPENCSGDIR # OPENSCAD_LIBRARIES # -# Please see the 'Building' sections of the OpenSCAD user manual +# qmake Variables to define the installation: +# +# PREFIX defines the base installation folder +# LOCALE_PREFIX can overwrite the location of the gettext message catalogs +# +# Please see the 'Building' sections of the OpenSCAD user manual # for updated tips & workarounds. # # http://en.wikibooks.org/wiki/OpenSCAD_User_Manual @@ -473,6 +478,19 @@ isEmpty(PREFIX):PREFIX = /usr/local target.path = $$PREFIX/bin/ INSTALLS += target +LINGUAS = $$cat(po/LINGUAS) +isEmpty(LOCALE_PREFIX):LOCALE_PREFIX = $$PREFIX/share/openscad/po +for(language, LINGUAS) { + catalog = po/$$language/LC_MESSAGES/openscad.mo + exists($$catalog) { + translation_path = translation_$${language}.path + translation_files = translation_$${language}.files + $$translation_path = $$LOCALE_PREFIX/$$language/LC_MESSAGES/ + $$translation_files = $$catalog + INSTALLS += translation_$$language + } +} + examples.path = $$PREFIX/share/openscad/examples/ examples.files = examples/* INSTALLS += examples diff --git a/src/openscad.cc b/src/openscad.cc index 2ca899b4..25a2c392 100644 --- a/src/openscad.cc +++ b/src/openscad.cc @@ -571,6 +571,7 @@ int gui(vector &inputFiles, const fs::path &original_path, int argc, cha PlatformUtils::registerApplicationPath(app_path.toLocal8Bit().constData()); parser_init(PlatformUtils::applicationPath()); + QSettings settings; if (settings.value("advanced/localization", false).toBool()) { localization_init(); diff --git a/src/parsersettings.cc b/src/parsersettings.cc index 189f6562..b47beccc 100644 --- a/src/parsersettings.cc +++ b/src/parsersettings.cc @@ -22,22 +22,38 @@ fs::path get_resource_dir(const std::string &resource_folder) } fs::path basepath(applicationdir); + + fs::path paths[] = { +#if __APPLE__ + // Application layout when installed on MacOS + basepath.parent_path().parent_path() / "Contents" / "Resources", +#endif +#ifdef __unix__ + // Different unix installation layouts are possible, this + // tries to capture the most obvious cases. + basepath.parent_path() / "share" / "openscad", + basepath.parent_path().parent_path() / "share" / "openscad", + fs::path("..") / "..", +#endif #ifdef OPENSCAD_TESTING - basepath = ".."; -#endif -#ifdef __APPLE__ - fs::path bundlepath = basepath.parent_path().parent_path(); - if (bundlepath.filename().string() == "OpenSCAD.app") { - basepath = bundlepath / "Contents" / "Resources"; - } + // Used when running the test cases from source code layout. + fs::path(".."), #endif + // Try to fall back to path relative to the executable and + // relative to the current working directory. + basepath, + fs::path("."), + fs::path(), // end of list marker + }; - fs::path resource_dir = basepath / resource_folder; - if (!fs::is_directory(resource_dir)) { - return fs::path(); + for (int a = 0;!paths[a].empty();a++) { + fs::path resource_dir = paths[a] / resource_folder; + if (fs::is_directory(resource_dir)) { + return resource_dir; + } } - return resource_dir; + return fs::path(); } /*!