Do not set C++ locale.

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.
This commit is contained in:
Robin Gareus 2017-04-20 22:12:18 +02:00
parent 9218ccb3b2
commit d4f91010c3
4 changed files with 1 additions and 54 deletions

View 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;

View 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
}
}

View 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;

View 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)