X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmessages.C;h=1877ae2f0b23ca72e096248f2ca04f1e9604fe3e;hb=37e82a546392d43f787826b85481a11f2a27af15;hp=d1aa3f52217c77a1bf95f0b17ca5c69bf9dd223e;hpb=384da17690b8bb35b6ec4f875be91825179262ed;p=lyx.git diff --git a/src/messages.C b/src/messages.C index d1aa3f5221..1877ae2f0b 100644 --- a/src/messages.C +++ b/src/messages.C @@ -13,6 +13,8 @@ #include "support/filetools.h" #include "support/path_defines.h" +#include + using lyx::support::GetEnvPath; using lyx::support::lyx_localedir; @@ -98,11 +100,24 @@ public: bindtextdomain(PACKAGE, lyx_localedir().c_str()); textdomain(PACKAGE); const char* msg = gettext(m.c_str()); - setlocale(LC_ALL, old); - free(old); + // Some english words have different translations, depending + // on context. In these cases the original string is + // augmented by context information (e.g. + // "To:[[as in 'From page x to page y']]" and + // "To:[[as in 'From format x to format y']]". + // This means that we need to filter out everything in + // double square brackets at the end of the string, + // otherwise the user sees bogus messages. // If we are unable to honour the request we just // return what we got in. - return (!n ? m : string(msg)); + string translated(n ? msg : m); + static boost::regex const reg("^([^\\[]*)\\[\\[[^\\]]*\\]\\]$"); + boost::smatch sub; + if (regex_match(translated, sub, reg)) + translated = sub.str(1); + setlocale(LC_ALL, old); + free(old); + return translated; } private: ///