From: Pavel Sanda Date: Wed, 14 Nov 2007 02:01:50 +0000 (+0000) Subject: Fix bug 2738: Wrong sorting of languages in Document dialog X-Git-Tag: 1.6.10~7358 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=1098ca796f97282a8d31b20eddc4a7eb7702a74c;p=features.git Fix bug 2738: Wrong sorting of languages in Document dialog http://bugzilla.lyx.org/show_bug.cgi?id=2738 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21598 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/qt4/qt_helpers.cpp b/src/frontends/qt4/qt_helpers.cpp index 7fe70acea3..1fc4fbbdc6 100644 --- a/src/frontends/qt4/qt_helpers.cpp +++ b/src/frontends/qt4/qt_helpers.cpp @@ -41,6 +41,7 @@ #include #include +#include using std::string; using std::vector; @@ -162,11 +163,34 @@ QString const qt_(string const & str) namespace { -struct Sorter +class Sorter { +public: +#if !defined(USE_WCHAR_T) && defined(__GNUC__) bool operator()(LanguagePair const & lhs, LanguagePair const & rhs) const { return lhs.first < rhs.first; } +#else + Sorter() : loc_ok(true) + { + try { + loc_ = std::locale(""); + } catch (...) { + loc_ok = false; + } + }; + + bool operator()(LanguagePair const & lhs, + LanguagePair const & rhs) const { + if (loc_ok) + return loc_(lhs.first, rhs.first); + else + return lhs.first < rhs.first; + } +private: + std::locale loc_; + bool loc_ok; +#endif };