Could someone please test this under Linux? Enrico, if you could test it under Cygwin as well, that would be great.
Thanks in advance, Abdel.
Index: messages.C =================================================================== --- messages.C (revision 16645) +++ messages.C (working copy) @@ -21,7 +21,10 @@ #include <boost/regex.hpp> #include <cerrno> +#include <map> +using std::endl; +using std::string; namespace lyx { @@ -29,10 +32,7 @@ using support::getEnv; using support::setEnv; -using std::string; -using std::endl; - static boost::regex const reg("^([^\\[]*)\\[\\[[^\\]]*\\]\\]$"); @@ -114,11 +114,16 @@ ~Pimpl() {} - docstring const get(string const & m) const + docstring const & get(string const & m) const { + static docstring empty_string; if (m.empty()) - return from_ascii(m); + return empty_string; + CacheType::iterator it = cache_.find(m); + if (it != cache_.end()) + return it->second; + // In this order, see support/filetools.C: string lang = getEnv("LC_ALL"); if (lang.empty()) { @@ -206,11 +211,15 @@ setlocale(LC_MESSAGES, lang.c_str()); #endif setlocale(LC_CTYPE, oldCTYPE.c_str()); - return translated; + + it = cache_.insert(std::make_pair(m, translated)).first; + return it->second; } private: /// string lang_; + typedef std::map<string, docstring> CacheType; + mutable CacheType cache_; }; #endif @@ -250,7 +259,7 @@ {} -docstring const Messages::get(string const & msg) const +docstring const & Messages::get(string const & msg) const { return pimpl_->get(msg); } Index: messages.h =================================================================== --- messages.h (revision 16645) +++ messages.h (working copy) @@ -29,7 +29,7 @@ /// ~Messages(); /// - docstring const get(std::string const & msg) const; + docstring const & get(std::string const & msg) const; private: class Pimpl; boost::scoped_ptr<Pimpl> pimpl_;