]> git.lyx.org Git - features.git/commitdiff
fix bug 2177
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Sat, 28 Jan 2006 20:13:10 +0000 (20:13 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Sat, 28 Jan 2006 20:13:10 +0000 (20:13 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10790 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/messages.C

index 8226045f6cce97c44c5cc13ea74417fede518cbe..e08d16113ca4339fc6becfba7774bbfc81e1a73a 100644 (file)
@@ -1,3 +1,7 @@
+2006-01-28  Georg Baum  <Georg.Baum@post.rwth-aachen.de>
+
+       * messages.C (get): Only warn once if setlocale fails (bug 2177)
+
 2006-01-28  Martin Vermeer  <martin.vermeer@hut.fi>
 
        * text2.C (setCharFont): take inset's own font settings into account
index 3baa83c3e451be4f77df6adc984b33d213e6f47a..989bb9a0d0c5b84bd0b48d0948d2105cbe455be9 100644 (file)
@@ -107,7 +107,6 @@ public:
                if (m.empty())
                        return m;
 
-               //string oldMSG = setlocale(LC_MESSAGES, NULL);
                // In this order, see support/filetools.C:
                string lang = getEnv("LC_ALL");
                if (lang.empty()) {
@@ -120,9 +119,17 @@ public:
                }
                
                char const * lc_msgs = setlocale(LC_MESSAGES, lang_.c_str());
+               // setlocale fails (returns NULL) if the corresponding locale
+               // is not installed.
+               // On windows (mingw) it always returns NULL.
+               // Since this method gets called for every translatable
+               // buffer string like e.g. "Figure:" we warn only once.
 #ifndef _WIN32
-               if (!lc_msgs)
+               static bool warned = false;
+               if (!warned && !lc_msgs) {
+                       warned = true;
                        lyxerr << "Locale " << lang_ << " could not be set" << std::endl;
+               }
 #endif
                // CTYPE controls what getmessage thinks what encoding the po file uses
                char const * lc_ctype = setlocale(LC_CTYPE, NULL);