00001
00002 #ifndef _CI18NTRANSLATOR
00003 #define _CI18NTRANSLATOR
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include <map>
00027 #include <string>
00028 #include "libMRML/include/CXMLElement.h"
00029 #include <expat.h>
00030
00036 class CI18nTranslator{
00038 typedef map<string,string> CTranslatorMap;
00041 typedef map<string,bool> CShouldBeTranslatedMap;
00043 typedef map<string,CTranslatorMap> CLanguageMap;
00044
00049 CLanguageMap mLanguageMap;
00053 CShouldBeTranslatedMap mShouldBeTranslatedAttribute;
00057 string mCurrentLanguage;
00058
00059
00060 protected:
00061 public:
00063 bool shouldBeTranslatedAttribute(string inAttribute)const;
00065 bool shouldBeTranslatedText(string inContainingTag)const;
00067 void setCurrentLanguage(const string& inLanguage);
00069 string getCurrentLanguage()const;
00071 void setShouldBeTranslatedAttribute(string inString);
00073 void addTranslationPair(string inString,string inTranslatedString);
00074
00076 CI18nTranslator(string inTranslationFileName);
00078 const CXMLElement* getLanguagesXML()const;
00080 bool hasLanguage(string inLanguageCode)const;
00085 const pair<bool,string> translateAttribute(string inLanguageCode,
00086 const string& inAttribute,
00087 const string& inValue)const;
00092 const pair<bool,string> translateText(string inLanguageCode,
00093 const string& inContainingTag,
00094 const string& inText);
00096 void translateXMLTree(string inLanguageCode,
00097 CXMLElement& inoutToBeTranslated)const;
00099 static void CI18nTranslator::startXMLElement(void *inUserData,
00100 const char *inElementName,
00101 const char **inAttributes);
00103 static void CI18nTranslator::endXMLElement(void *inUserData,
00104 const char *inElementName);
00105 };
00106 #endif