Commit ff99636a authored by Daniel Elstner's avatar Daniel Elstner
Browse files

Print a warning message to the console if the format string contains an

* src/translation.cc (compose_impl): Print a warning message to
the console if the format string contains an invalid substitution,
rather than just silently ignoring the error.  This is mainly of
importance to translators, as it provides them some feedback if
they get it wrong.
parent b82ada01
2004-05-25 Daniel Elstner <daniel.elstner@gmx.net>
* src/translation.cc (compose_impl): Print a warning message to
the console if the format string contains an invalid substitution,
rather than just silently ignoring the error. This is mainly of
importance to translators, as it provides them some feedback if
they get it wrong.
2004-05-25 Daniel Elstner <daniel.elstner@gmx.net>
* src/filetree.cc (regexxer_create_file_tree): Move to anonymous
......
......@@ -25,9 +25,9 @@
#include "translation.h"
#include <glib.h>
#include <glibmm.h>
#include <vector>
#include <cstring>
namespace
......@@ -49,16 +49,24 @@ Glib::ustring compose_impl(const Glib::ustring& format, const std::vector<Glib::
if (uc == '%' && p != pend)
{
uc = *p++;
const int index = Glib::Unicode::digit_value(uc) - 1;
if (index >= 0 && unsigned(index) < args.size())
if (uc != '%')
{
result += args[index];
continue;
}
const int index = Glib::Unicode::digit_value(uc) - 1;
if (uc != '%')
result += '%';
if (index >= 0 && unsigned(index) < args.size())
{
result += args[index];
continue;
}
const Glib::ustring buf (1, uc);
g_warning("Util::compose(): invalid substitution `%%%s' in format string `%s'",
buf.c_str(), format.c_str());
result += '%'; // print invalid substitutions literally
}
}
result += uc;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment