20 #include <boost/function.hpp>
21 #include <vlutil/vlStringUtil.h>
31 typedef boost::function<std::string (const char* module, const char* stringToTranslate)>
TranslationFunction;
68 virtual void printTo(DtOutputStream&)
const;
70 virtual void addTranslatableString(
const DtString&,
const DtString& module =
"DtRwTranslatableStringObject",
71 const DtString& originalString =
"");
72 virtual void addArgument(
const DtString&);
76 virtual std::string toFormattedString(
bool finalCR =
true)
const;
84 virtual std::vector<int> typesFrom(
const std::string& fmt, std::string& reformatted)
const;
93 unsigned int argsTranslated = 0;
97 std::vector<std::string> results;
100 oldBoostSplit(results, source, boost::algorithm::is_any_of(
"="));
104 if (results[0] ==
"translate")
107 std::string toTranslate = (*iterator.
current()).c_str();
108 if (results.size() >= 2)
112 if (results.size() == 3)
114 toTranslate = results[2];
122 std::string translated = (theTranslatorFunction)(module.c_str(), toTranslate.c_str()).c_str();
124 if (translated == toTranslate.c_str())
126 translated = (*iterator.
current()).c_str();
129 result += translated;
131 else if (results[0] ==
"argument")
133 result = DtReplaceSubstring(result,
"%1", iterator.
current()->c_str());
137 result = DtReplaceSubstring(result,
"%" +
DtString(argsTranslated + 1),
"%1");
148 if (finalCR && (!result.length() || result[result.length() - 1] !=
'\n'))
159 static std::string defaultTranslationFunction(
const char* module,
const char* toTranslate) {
return toTranslate; };