]> git.lyx.org Git - features.git/commitdiff
Introduce Debug::LOCALE for locale debugging.
authorAbdelrazak Younes <younes@lyx.org>
Wed, 25 Jun 2008 10:53:34 +0000 (10:53 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Wed, 25 Jun 2008 10:53:34 +0000 (10:53 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25385 a592a061-630c-0410-9148-cb99ea01b6c8

src/support/Messages.cpp
src/support/debug.cpp
src/support/debug.h

index b9a5bb5545cbb1436ef983eb882ce2bd7683fac4..5a921953c2eaf709aa18b6f58322555826913b93 100644 (file)
@@ -74,7 +74,7 @@ Messages::Messages(string const & l)
        // strip off any encoding suffix, i.e., assume 8-bit po files
        size_t i = lang_.find(".");
        lang_ = lang_.substr(0, i);
-       LYXERR(Debug::DEBUG, "language(" << lang_ << ")");
+       LYXERR(Debug::LOCALE, "language(" << lang_ << ")");
 }
 
 
@@ -85,13 +85,13 @@ void Messages::init()
        char const * c = bindtextdomain(PACKAGE, locale_dir.c_str());
        int e = errno;
        if (e) {
-               LYXERR(Debug::DEBUG, "Error code: " << errno << '\n'
+               LYXERR(Debug::LOCALE, "Error code: " << errno << '\n'
                        << "Directory : " << package().locale_dir().absFilename() << '\n'
                        << "Rtn value : " << c);
        }
 
        if (!bind_textdomain_codeset(PACKAGE, ucs4_codeset)) {
-               LYXERR(Debug::DEBUG, "Error code: " << errno << '\n'
+               LYXERR(Debug::LOCALE, "Error code: " << errno << '\n'
                        << "Codeset   : " << ucs4_codeset);
        }
 
@@ -116,18 +116,18 @@ docstring const Messages::get(string const & m) const
        if (!lang_.empty()) {
                // This GNU extension overrides any language locale
                // wrt gettext.
-               bool success = setEnv("LANGUAGE", lang_);
-               if (!success)
-                       LYXERR0("WARNING: Cannot set env LANGUAGE variable to " << lang_);
+               LYXERR(Debug::LOCALE, "Setting LANGUAGE to " << lang_);
+               if (!setEnv("LANGUAGE", lang_))
+                       LYXERR(Debug::LOCALE, "\t... failed!");
                // However, setting LANGUAGE does nothing when the
                // locale is "C". Therefore we set the locale to
                // something that is believed to exist on most
                // systems. The idea is that one should be able to
                // load German documents even without having de_DE
                // installed.
-               success = setEnv("LC_ALL", "en_US");
-               if (!success)
-                       LYXERR0("WARNING: Cannot set env LC_ALL variable to en_US");
+               LYXERR(Debug::LOCALE, "Setting LC_ALL to en_US");
+               if (!setEnv("LC_ALL", "en_US"))
+                       LYXERR(Debug::LOCALE, "\t... failed!");
 #ifdef HAVE_LC_MESSAGES
                setlocale(LC_MESSAGES, "");
 #endif
@@ -137,12 +137,12 @@ docstring const Messages::get(string const & m) const
        char const * trans_c = gettext(m_c);
        docstring trans;
        if (!trans_c)
-               LYXERR0("Undefined result from gettext");
+               LYXERR(Debug::LOCALE, "Undefined result from gettext");
        else if (trans_c == m_c) {
-               LYXERR(Debug::DEBUG, "Same as entered returned");
+               LYXERR(Debug::LOCALE, "Same as entered returned");
                trans = from_ascii(m);
        } else {
-               LYXERR(Debug::DEBUG, "We got a translation");
+               //LYXERR(Debug::LOCALE, "We got a translation");
                // m is actually not a char const * but ucs4 data
                trans = reinterpret_cast<char_type const *>(trans_c);
        }
@@ -152,8 +152,14 @@ docstring const Messages::get(string const & m) const
        // Reset environment variables as they were.
        if (!lang_.empty()) {
                // Reset everything as it was.
-               setEnv("LANGUAGE", oldLANGUAGE);
-               setEnv("LC_ALL", oldLC_ALL);
+               LYXERR(Debug::LOCALE, "restoring LANGUAGE from " << getEnv("LANGUAGE")
+                       << " to " << oldLANGUAGE);
+               if (!setEnv("LANGUAGE", oldLANGUAGE))
+                       LYXERR(Debug::LOCALE, "\t... failed!");
+               LYXERR(Debug::LOCALE, "restoring LC_ALL from " << getEnv("LC_ALL")
+                       << " to " << oldLC_ALL);
+               if (!setEnv("LC_ALL", oldLC_ALL))
+                       LYXERR(Debug::LOCALE, "\t... failed!");
 #ifdef HAVE_LC_MESSAGES
                setlocale(LC_MESSAGES, "");
 #endif
index 85ef9f31745b69b97a57c3e4106c85cb1f2dd7a1..aebc0c44a04aa55b8d41aae3053fcd73a0f507f0 100644 (file)
@@ -64,6 +64,7 @@ ErrorItem errorTags[] = {
        { Debug::SCROLLING, "scrolling", N_("scrolling debugging")},
        { Debug::MACROS,    "macros",    N_("Math macros")},
        { Debug::RTL,       "rtl",       N_("RTL/Bidi")},
+       { Debug::LOCALE,    "locale",    N_("Locale/Internationalisation")},
        { Debug::DEBUG,     "debug",     N_("Developers' general debug messages")},
        { Debug::ANY,       "any",       N_("All debugging messages")}
 };
index d1cd19b112306a9f144badb87e18fa4710100c7b..a3045bcf88fc9a7bdffb44a9d4d054cc66658dd7 100644 (file)
@@ -95,6 +95,8 @@ namespace Debug {
                MACROS     = (1 << 26),
                ///     rtl-related
                RTL        = (1 << 27),
+               ///     locale related
+               LOCALE        = (1 << 28),
                ///
                DEBUG      = (1 << 31),
                ///