// Author: Vitaly SMETANNIKOV
#include "Config_Translator.h"
-#include <Config_XMLReader.h>
+#include "Config_XMLReader.h"
+#include "Config_Common.h"
class Config_TSReader : public Config_XMLReader
{
void Config_TSReader::processNode(xmlNodePtr theNode)
{
+ static std::string aName;
+ static std::string aSource;
+ std::string aTranslat;
+
+ if (isNode(theNode, "context", NULL)) {
+ aName = "";
+ } else if (isNode(theNode, "name", NULL)) {
+ aName = getContent(theNode);
+ } else if (isNode(theNode, "message", NULL)) {
+ aSource = "";
+ } else if (isNode(theNode, "source", NULL)) {
+ aSource = getContent(theNode);
+ } else if (isNode(theNode, "translation", NULL)) {
+ aTranslat = getContent(theNode);
+ if ((aName.size() > 0) && (aSource.size() > 0))
+ myTranslator[aName][aSource] = aTranslat;
+ }
}
+//******************************************************************************
+//******************************************************************************
+//******************************************************************************
+Config_Translator::Translator Config_Translator::myTranslator;
bool Config_Translator::load(const std::string& theFileName)
{
const Translator& aTranslator = aReader.translator();
Translator::const_iterator aIt;
+ std::string aContext;
+ Dictionary aDictionary;
for (aIt = aTranslator.cbegin(); aIt != aTranslator.cend(); aIt++) {
+ aContext = (*aIt).first;
+ aDictionary = (*aIt).second;
+ if (myTranslator.count(aContext) == 0) {
+ myTranslator[aContext] = aDictionary;
+ } else {
+ Dictionary::const_iterator aDictIt;
+ for (aDictIt = aDictionary.cbegin(); aDictIt != aDictionary.cend(); aDictIt++) {
+ myTranslator[aContext][(*aDictIt).first] = (*aDictIt).second;
+ }
+ }
}
return true;
std::string Config_Translator::translate(const Events_InfoMessage& theInfo)
{
+ std::string aContext = theInfo.context();
+ std::string aMessage = theInfo.message();
+ std::list<std::string> aParameters = theInfo.parameters();
+ if (myTranslator.count(aContext) > 0) {
+ if (myTranslator[aContext].count(aMessage) > 0) {
+ std::string aTranslation = myTranslator[aContext][aMessage];
+ if (aParameters.size() > 0) {
+ std::list<std::string>::const_iterator aIt;
+ int i;
+ char aBuf[20];
+ std::string aParam;
+ for (i=1, aIt = aParameters.cbegin(); aIt != aParameters.cend(); aIt++, i++) {
+ aParam = (*aIt);
+ sprintf(aBuf, "%d ", i);
+ std::string aCode = std::string("%") + std::string(aBuf);
+ size_t aPos = aTranslation.find(aCode);
+ if (aPos != std::string::npos) {
+ std::string aFirst = aTranslation.substr(0, aPos);
+ std::string aLast = aTranslation.substr(aPos + aCode.length(), std::string::npos);
+ aTranslation = aFirst + aParam + aLast;
+ }
+ }
+ }
+ return aTranslation;
+ }
+ }
return "";
}
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="XGUI_Workshop.cpp" line="112"/>
+ <location filename="XGUI_Workshop.cpp" line="113"/>
<source>Move to the end</source>
<translation type="unfinished"></translation>
</message>
<context>
<name>XGUI_Workshop</name>
<message>
- <location filename="XGUI_Workshop.cpp" line="290"/>
- <location filename="XGUI_Workshop.cpp" line="344"/>
+ <location filename="XGUI_Workshop.cpp" line="300"/>
+ <location filename="XGUI_Workshop.cpp" line="354"/>
<source>Undo</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="XGUI_Workshop.cpp" line="291"/>
- <location filename="XGUI_Workshop.cpp" line="344"/>
+ <location filename="XGUI_Workshop.cpp" line="301"/>
+ <location filename="XGUI_Workshop.cpp" line="354"/>
<source>Undo last command</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="XGUI_Workshop.cpp" line="294"/>
+ <location filename="XGUI_Workshop.cpp" line="304"/>
<source>INF_DESK_TOOLBAR_STANDARD</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="XGUI_Workshop.cpp" line="300"/>
- <location filename="XGUI_Workshop.cpp" line="353"/>
+ <location filename="XGUI_Workshop.cpp" line="310"/>
+ <location filename="XGUI_Workshop.cpp" line="363"/>
<source>Redo</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="XGUI_Workshop.cpp" line="300"/>
- <location filename="XGUI_Workshop.cpp" line="353"/>
+ <location filename="XGUI_Workshop.cpp" line="310"/>
+ <location filename="XGUI_Workshop.cpp" line="363"/>
<source>Redo last command</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="XGUI_Workshop.cpp" line="317"/>
+ <location filename="XGUI_Workshop.cpp" line="327"/>
<source>Export native...</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="XGUI_Workshop.cpp" line="317"/>
+ <location filename="XGUI_Workshop.cpp" line="327"/>
<source>Export the current document into a native file</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="XGUI_Workshop.cpp" line="322"/>
+ <location filename="XGUI_Workshop.cpp" line="332"/>
<source>Import native...</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="XGUI_Workshop.cpp" line="322"/>
+ <location filename="XGUI_Workshop.cpp" line="332"/>
<source>Import native file</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="XGUI_Workshop.cpp" line="334"/>
- <location filename="XGUI_Workshop.cpp" line="823"/>
+ <location filename="XGUI_Workshop.cpp" line="344"/>
+ <location filename="XGUI_Workshop.cpp" line="833"/>
<source>Save</source>
<extracomment>Title of the dialog which asks user if he wants to save study in existing non-empty folder</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="XGUI_Workshop.cpp" line="334"/>
+ <location filename="XGUI_Workshop.cpp" line="344"/>
<source>Save the document</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="XGUI_Workshop.cpp" line="339"/>
+ <location filename="XGUI_Workshop.cpp" line="349"/>
<source>Save as...</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="XGUI_Workshop.cpp" line="339"/>
+ <location filename="XGUI_Workshop.cpp" line="349"/>
<source>Save the document into a file</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="XGUI_Workshop.cpp" line="367"/>
+ <location filename="XGUI_Workshop.cpp" line="377"/>
<source>Open...</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="XGUI_Workshop.cpp" line="367"/>
+ <location filename="XGUI_Workshop.cpp" line="377"/>
<source>Open a new document</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="XGUI_Workshop.cpp" line="371"/>
+ <location filename="XGUI_Workshop.cpp" line="381"/>
<source>Preferences</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="XGUI_Workshop.cpp" line="371"/>
+ <location filename="XGUI_Workshop.cpp" line="381"/>
<source>Edit preferences</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="XGUI_Workshop.cpp" line="375"/>
+ <location filename="XGUI_Workshop.cpp" line="385"/>
<source>Exit</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="XGUI_Workshop.cpp" line="375"/>
+ <location filename="XGUI_Workshop.cpp" line="385"/>
<source>Exit application</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="XGUI_Workshop.cpp" line="685"/>
- <location filename="XGUI_Workshop.cpp" line="741"/>
+ <location filename="XGUI_Workshop.cpp" line="695"/>
+ <location filename="XGUI_Workshop.cpp" line="751"/>
<source>Save current file</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="XGUI_Workshop.cpp" line="686"/>
+ <location filename="XGUI_Workshop.cpp" line="696"/>
<source>The document is modified, save before opening another?</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="XGUI_Workshop.cpp" line="697"/>
+ <location filename="XGUI_Workshop.cpp" line="707"/>
<source>Select directory</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="XGUI_Workshop.cpp" line="702"/>
+ <location filename="XGUI_Workshop.cpp" line="712"/>
<source>Warning</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="XGUI_Workshop.cpp" line="702"/>
+ <location filename="XGUI_Workshop.cpp" line="712"/>
<source>Unable to open the file.</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="XGUI_Workshop.cpp" line="741"/>
+ <location filename="XGUI_Workshop.cpp" line="751"/>
<source>The document is modified, save before exit?</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="XGUI_Workshop.cpp" line="807"/>
+ <location filename="XGUI_Workshop.cpp" line="817"/>
<source>Select directory to save files...</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="XGUI_Workshop.cpp" line="809"/>
+ <location filename="XGUI_Workshop.cpp" line="819"/>
<source>Directories (*)</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="XGUI_Workshop.cpp" line="824"/>
+ <location filename="XGUI_Workshop.cpp" line="834"/>
<source>The directory already contains some files, save anyway?</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="XGUI_Workshop.cpp" line="957"/>
+ <location filename="XGUI_Workshop.cpp" line="967"/>
<source>Information about module "%1" doesn't exist.</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="XGUI_Workshop.cpp" line="1088"/>
+ <location filename="XGUI_Workshop.cpp" line="1098"/>
<source>Object browser</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="XGUI_Workshop.cpp" line="1420"/>
+ <location filename="XGUI_Workshop.cpp" line="1430"/>
<source>Unused features are the following: %1.
These features will be deleted.
Would you like to continue?</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="XGUI_Workshop.cpp" line="1458"/>
+ <location filename="XGUI_Workshop.cpp" line="1468"/>
<source>All features are relevant, there is nothing to be deleted</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="XGUI_Workshop.cpp" line="1958"/>
+ <location filename="XGUI_Workshop.cpp" line="1968"/>
<source>Find results</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="XGUI_Workshop.cpp" line="1959"/>
+ <location filename="XGUI_Workshop.cpp" line="1969"/>
<source>Results not found</source>
<translation type="unfinished"></translation>
</message>