diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2013-01-23 18:44:16 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2013-01-23 18:44:16 +0000 |
commit | bc2523c2495f87cc0df0f3496c96cf0fef4d746d (patch) | |
tree | 72c5a9bb766ed9fcc87304ab6ef32a5ecdb272b2 /libs | |
parent | f08f3acbacfbbe23b2aa7c1720043eb37d3ee6b9 (diff) |
new logic for enabling translation in bundled releases of ardour
git-svn-id: svn://localhost/ardour2/branches/3.0@13980 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/ardour/ardour.h | 6 | ||||
-rw-r--r-- | libs/ardour/globals.cc | 37 |
2 files changed, 36 insertions, 7 deletions
diff --git a/libs/ardour/ardour/ardour.h b/libs/ardour/ardour/ardour.h index 26e875fda3..5f64c4b6a3 100644 --- a/libs/ardour/ardour/ardour.h +++ b/libs/ardour/ardour/ardour.h @@ -62,8 +62,10 @@ namespace ARDOUR { void find_bindings_files (std::map<std::string,std::string>&); - std::string translation_kill_path (); - bool translations_are_disabled (); + /* these only impact bundled installations */ + std::string translation_enable_path (); + bool translations_are_enabled (); + bool set_translations_enabled (bool); static inline microseconds_t get_microseconds () { return (microseconds_t) jack_get_time(); diff --git a/libs/ardour/globals.cc b/libs/ardour/globals.cc index c23cb614fe..b21f3038bb 100644 --- a/libs/ardour/globals.cc +++ b/libs/ardour/globals.cc @@ -21,6 +21,7 @@ #endif #include <cstdio> // Needed so that libraptor (included in lrdf) won't complain +#include <cstdlib> #include <sys/stat.h> #include <sys/types.h> #include <sys/time.h> @@ -465,19 +466,45 @@ ARDOUR::setup_fpu () #endif } +/* this can be changed to modify the translation behaviour for + cases where the user has never expressed a preference. +*/ +static const bool translate_by_default = true; + string -ARDOUR::translation_kill_path () +ARDOUR::translation_enable_path () +{ + return Glib::build_filename (user_config_directory(), ".translate"); +} + +bool +ARDOUR::translations_are_enabled () { - return Glib::build_filename (user_config_directory(), ".love_is_the_language_of_audio"); + if (Glib::file_test (translation_enable_path(), Glib::FILE_TEST_EXISTS)) { + return true; + } + + return translate_by_default; } bool -ARDOUR::translations_are_disabled () +ARDOUR::set_translations_enabled (bool yn) { - /* if file does not exist, we don't translate (bundled ardour only) */ - return Glib::file_test (translation_kill_path(), Glib::FILE_TEST_EXISTS) == false; + string i18n_enabler = ARDOUR::translation_enable_path(); + + if (yn) { + int fd = ::open (i18n_enabler.c_str(), O_RDONLY|O_CREAT, 0644); + if (fd >= 0) { + close (fd); + return true; + } + return false; + } + + return unlink (i18n_enabler.c_str()) == 0; } + vector<SyncSource> ARDOUR::get_available_sync_options () { |