Do not set C++ locale.
authorRobin Gareus <robin@gareus.org>
Thu, 20 Apr 2017 20:12:18 +0000 (22:12 +0200)
committerRobin Gareus <robin@gareus.org>
Thu, 20 Apr 2017 20:12:18 +0000 (22:12 +0200)
Ardour translations and GUI string formatting only depends on the C locale.
Modifying the C++ locale may produce erratic results on various systems
(in particular OSX and macOS) and cause incompatibilies with plugins.

gtk2_ardour/main.cc
gtk2_ardour/rc_option_editor.cc
gtk2_ardour/rc_option_editor.h
gtk2_ardour/ui_config_vars.h

index 3d4e2da20f87d6ce79abac9a2a0c20a698a5a8cb..10c9c306e71c65fd05d5bd7818fcfe9f1e37174d 100644 (file)
@@ -304,24 +304,9 @@ int main (int argc, char *argv[])
 #endif
 
 #ifdef ENABLE_NLS
-       /* initialize C and C++ locales to user preference */
-       char* l_msg = NULL;
-       char* l_num = NULL;
+       /* initialize C locale to user preference */
        if (ARDOUR::translations_are_enabled ()) {
                setlocale (LC_ALL, "");
-               try {
-                       std::locale::global (std::locale (setlocale (LC_ALL, 0)));
-               } catch (...) {
-                       std::cerr << "Cannot set C++ locale\n";
-               }
-#ifndef COMPILER_MSVC
-               // LC_MESSAGES isn't a supported locale setting when building
-               // with MSVC (in fact, I doubt if it's valid for Windows at all)
-               l_msg = setlocale (LC_MESSAGES, NULL);
-#endif
-               l_num = setlocale (LC_NUMERIC, NULL);
-               if (l_msg) { l_msg = strdup (l_msg); }
-               if (l_num) { l_num = strdup (l_num); }
        }
 #endif
 
@@ -399,25 +384,6 @@ int main (int argc, char *argv[])
                return curvetest (curvetest_file);
        }
 
-#ifdef ENABLE_NLS
-       ARDOUR::LocaleMode locale_mode = UIConfiguration::instance().get_locale_mode ();
-       if (l_msg && l_num && locale_mode != ARDOUR::SET_LC_ALL) {
-               try {
-                       std::locale cpp_locale (std::locale::classic ());
-                       cpp_locale = std::locale (cpp_locale, l_msg, std::locale::messages);
-                       if (ARDOUR::SET_LC_MESSAGES_AND_LC_NUMERIC == locale_mode) {
-                               cpp_locale = std::locale (cpp_locale, l_num, std::locale::numeric);
-                       }
-                       std::locale::global (cpp_locale);
-               } catch (...) {
-                       std::cerr << "Cannot override C++ locale\n";
-               }
-               info << "LC_ALL: " << setlocale (LC_ALL, NULL) << endmsg;
-       }
-       free (l_msg);
-       free (l_num);
-#endif
-
 #ifndef PLATFORM_WINDOWS
        if (::signal (SIGPIPE, sigpipe_handler)) {
                cerr << _("Cannot xinstall SIGPIPE error handler") << endl;
index 674ec2c88ab0fd59a5e3e3d4e08f2955140e86ec..84034ae6331dec5992c4482d91e87bbd60aebaa9 100644 (file)
@@ -2296,19 +2296,6 @@ RCOptionEditor::RCOptionEditor ()
 
        add_option (_("General/Translation"), bo);
 
-       _l10n = new ComboOption<ARDOUR::LocaleMode> (
-               "locale-mode",
-               _("Localization"),
-               sigc::mem_fun (UIConfiguration::instance(), &UIConfiguration::get_locale_mode),
-               sigc::mem_fun (UIConfiguration::instance(), &UIConfiguration::set_locale_mode)
-               );
-
-       _l10n->add (ARDOUR::SET_LC_ALL, _("Set complete locale"));
-       _l10n->add (ARDOUR::SET_LC_MESSAGES, _("Enable only message translation"));
-       _l10n->add (ARDOUR::SET_LC_MESSAGES_AND_LC_NUMERIC, _("Translate messages and format numeric format"));
-       _l10n->set_note (_("This setting is provided for plugin compatibility. e.g. some plugins on some systems expect the decimal point to be a dot."));
-
-       add_option (_("General/Translation"), _l10n);
        parameter_changed ("enable-translation");
 #endif // ENABLE_NLS
 
@@ -3971,10 +3958,6 @@ RCOptionEditor::parameter_changed (string const & p)
        } else if (p == "open-gui-after-adding-plugin" || p == "show-inline-display-by-default") {
 #if (defined LV2_SUPPORT && defined LV2_EXTENDED)
                _plugin_prefer_inline->set_sensitive (UIConfiguration::instance().get_open_gui_after_adding_plugin() && UIConfiguration::instance().get_show_inline_display_by_default());
-#endif
-#ifdef ENABLE_NLS
-       } else if (p == "enable-translation") {
-               _l10n->set_sensitive (ARDOUR::translations_are_enabled ());
 #endif
        }
 }
index e0d0116c36da204b0c40fad46468e8df1c88b4ec..d6c5bed4a7f4744cc4125691b9be4632fec13640 100644 (file)
@@ -60,7 +60,6 @@ private:
        Gtk::Adjustment* _ltc_volume_adjustment;
        BoolOption* _ltc_send_continuously;
        BoolOption* _plugin_prefer_inline;
-       ComboOption<ARDOUR::LocaleMode>* _l10n;
 
        PBD::ScopedConnection parameter_change_connection;
        PBD::ScopedConnection engine_started_connection;
index 53a02865a71b59b8c8e5ca44d6a2f73709ee0d3d..ae94452c96a3cca37b42a042cfdf587875c13347 100644 (file)
@@ -70,7 +70,6 @@ UI_CONFIG_VARIABLE (float, meter_hold, "meter-hold", 100.0f)
 UI_CONFIG_VARIABLE (ARDOUR::VUMeterStandard, meter_vu_standard, "meter-vu-standard", ARDOUR::MeteringVUstandard)
 UI_CONFIG_VARIABLE (ARDOUR::MeterLineUp, meter_line_up_level, "meter-line-up-level", ARDOUR::MeteringLineUp18)
 UI_CONFIG_VARIABLE (ARDOUR::MeterLineUp, meter_line_up_din, "meter-line-up-din", ARDOUR::MeteringLineUp15)
-UI_CONFIG_VARIABLE (ARDOUR::LocaleMode, locale_mode, "locale-mode", ARDOUR::SET_LC_ALL)
 UI_CONFIG_VARIABLE (float, meter_peak, "meter-peak", 0.0f)
 UI_CONFIG_VARIABLE (bool, meter_style_led, "meter-style-led", false)
 UI_CONFIG_VARIABLE (bool, show_editor_meter, "show-editor-meter", true)