From 8fea36cdd034fa15a5cefa997ea1ed29b5115d23 Mon Sep 17 00:00:00 2001 From: Gallaecio Date: Sat, 26 Apr 2014 15:32:18 +0000 Subject: [PATCH] =?UTF-8?q?Made=20tinygettext=E2=80=99s=20debug=20output?= =?UTF-8?q?=20optional?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit You can now enable tinygettext’s output from the user.cfg file (tinygettext.debug). This enhancement also solved a warning due to the previous workaround, which was to uncomment the output line to avoid the debug messages. This issue was reported by Yves at Github: https://github.com/leper/0ad/issues/10 This was SVN commit r15002. --- binaries/data/config/default.cfg | 3 +++ source/i18n/L10n.cpp | 11 +++++++++++ source/lib/external_libraries/tinygettext.h | 1 + source/third_party/tinygettext/src/log.cpp | 2 +- 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/binaries/data/config/default.cfg b/binaries/data/config/default.cfg index 3d81e114f2..121d4a8ec0 100644 --- a/binaries/data/config/default.cfg +++ b/binaries/data/config/default.cfg @@ -332,6 +332,9 @@ profiler2.gpu.intel.enable = true ; Allow GL_INTEL_performance_queries ; > JS DEBUGGER jsdebugger.enable = false ; Enable Javascript debugging. The Debugger is currently broken and can't be enabled until the SpiderMonkey upgrade is done and the debugger is updated for the new API. +; > TINYGETTEXT DEBUGGING +tinygettext.debug = false ; Enable Tinygettext debugging information. If true, Tinygettext prints error messages each time that a translation for an English string is not found. + ; > QUICKSAVE hotkey.quicksave = "Shift+F5" hotkey.quickload = "Shift+F8" diff --git a/source/i18n/L10n.cpp b/source/i18n/L10n.cpp index 1d1e0b7503..990613d329 100644 --- a/source/i18n/L10n.cpp +++ b/source/i18n/L10n.cpp @@ -45,6 +45,17 @@ L10n& L10n::Instance() L10n::L10n() : currentLocaleIsOriginalGameLocale(false), useLongStrings(false), dictionary(new tinygettext::Dictionary()) { + // Determine whether or not to print tinygettext messages to the standard + // error output, which it tinygettext’s default behavior, but not ours. + bool tinygettext_debug = false; + CFG_GET_VAL("tinygettext.debug", Bool, tinygettext_debug); + if (!tinygettext_debug) + { + tinygettext::Log::log_info_callback = 0; + tinygettext::Log::log_warning_callback = 0; + tinygettext::Log::log_error_callback = 0; + } + LoadListOfAvailableLocales(); ReevaluateCurrentLocaleAndReload(); } diff --git a/source/lib/external_libraries/tinygettext.h b/source/lib/external_libraries/tinygettext.h index 20df3fefa4..4130c7cf67 100644 --- a/source/lib/external_libraries/tinygettext.h +++ b/source/lib/external_libraries/tinygettext.h @@ -35,6 +35,7 @@ #include #include +#include #if MSC_VERSION # pragma warning(pop) diff --git a/source/third_party/tinygettext/src/log.cpp b/source/third_party/tinygettext/src/log.cpp index 68e7e440a4..a3c11d2b9f 100644 --- a/source/third_party/tinygettext/src/log.cpp +++ b/source/third_party/tinygettext/src/log.cpp @@ -29,7 +29,7 @@ Log::log_callback_t Log::log_error_callback = &Log::default_log_callback; void Log::default_log_callback(const std::string& str) { -// std::cerr << "tinygettext: " << str; + std::cerr << "tinygettext: " << str; } void