Fallback to "C" locale if selected locale is not supported

This commit is contained in:
Moritz Bunkus 2010-02-24 16:32:29 +01:00
parent 0cff60d8ff
commit fa81e632b6
2 changed files with 12 additions and 6 deletions

View File

@ -1,3 +1,9 @@
2010-02-24 Moritz Bunkus <moritz@bunkus.org>
* All: bug fix: The programs will no longer abort with an error
message if a selected interface translation is not available. The
"C" locale is used instead. Fix for bug 472.
2010-02-23 Moritz Bunkus <moritz@bunkus.org>
* mkvmerge, mkvextract: enhancement: Improved the error resilience

View File

@ -263,12 +263,6 @@ init_locales(std::string locale) {
std::string loc_req_with_utf8 = locale_string_c(locale).set_codeset_and_modifier(locale_string_c("dummy.UTF-8")).str();
if (setlocale(LC_MESSAGES, loc_req_with_utf8.c_str()) != NULL)
chosen_locale = loc_req_with_utf8;
// Hard fallback to "C" locale if English was selected. This can
// happen if the system has no locales for "en_US" or
// "en_US.UTF-8" compiled.
else if ((locale_string_c(locale).str(locale_string_c::half) == "en_US") && (setlocale(LC_MESSAGES, "C") != NULL))
chosen_locale = "C";
}
} catch (locale_string_format_error_c &error) {
@ -279,6 +273,12 @@ init_locales(std::string locale) {
if (debugging_requested("locale"))
mxinfo(boost::format("[init_locales chosen locale %1%]\n") % chosen_locale);
// Hard fallback to "C" locale if no suitable locale was
// selected. This can happen if the system has no locales for
// "en_US" or "en_US.UTF-8" compiled.
if (chosen_locale.empty() && (setlocale(LC_MESSAGES, "C") != NULL))
chosen_locale = "C";
if (chosen_locale.empty())
mxerror(Y("The locale could not be set properly. Check the LANG, LC_ALL and LC_MESSAGES environment variables.\n"));