Bug 2177 complains about many error messages "Locale en_NZ could not be
set" for every character typed. I can almost reproduce this. The message
comes from the translation of buffer strings like "Figure:" or "Chapter".
I get 7 messages for every new paragraph I press in a french document (I
don't have the C-library support for french installed). I don't know why
we get so many messages, but even if we'd get only one for every
translated string thgis would be too much.
This is what I think should go in for 1.4.0 to fix bug 2177. OK?
Georg
Index: src/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v
retrieving revision 1.2364
diff -u -p -r1.2364 ChangeLog
--- src/ChangeLog 28 Jan 2006 12:39:21 -0000 1.2364
+++ src/ChangeLog 28 Jan 2006 16:08:06 -0000
@@ -1,3 +1,7 @@
+2006-01-28 Georg Baum <[EMAIL PROTECTED]>
+
+ * messages.C (get): Only warn once if setlocale fails (bug 2177)
+
2006-01-28 Martin Vermeer <[EMAIL PROTECTED]>
* text2.C (setCharFont): take inset's own font settings into account
Index: src/messages.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/messages.C,v
retrieving revision 1.26
diff -u -p -r1.26 messages.C
--- src/messages.C 3 Nov 2005 09:21:09 -0000 1.26
+++ src/messages.C 28 Jan 2006 16:08:06 -0000
@@ -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);