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
00027
00028 #include <map>
00029 #include <string>
00030 #include "libMRML/include/CXMLElement.h"
00031 #include <expat.h>
00032
00038 class CI18nTranslator{
00040 typedef map<string,string> CTranslatorMap;
00043 typedef map<string,bool> CShouldBeTranslatedMap;
00045 typedef map<string,CTranslatorMap> CLanguageMap;
00046
00051 CLanguageMap mLanguageMap;
00055 CShouldBeTranslatedMap mShouldBeTranslatedAttribute;
00059 string mCurrentLanguage;
00060
00061
00062 protected:
00063 public:
00065 bool shouldBeTranslatedAttribute(string inAttribute)const;
00067 bool shouldBeTranslatedText(string inContainingTag)const;
00069 void setCurrentLanguage(const string& inLanguage);
00071 string getCurrentLanguage()const;
00073 void setShouldBeTranslatedAttribute(string inString);
00075 void addTranslationPair(string inString,string inTranslatedString);
00076
00078 CI18nTranslator(string inTranslationFileName);
00080 const CXMLElement* getLanguagesXML()const;
00082 bool hasLanguage(string inLanguageCode)const;
00087 const pair<bool,string> translateAttribute(string inLanguageCode,
00088 const string& inAttribute,
00089 const string& inValue)const;
00094 const pair<bool,string> translateText(string inLanguageCode,
00095 const string& inContainingTag,
00096 const string& inText);
00098 void translateXMLTree(string inLanguageCode,
00099 CXMLElement& inoutToBeTranslated)const;
00101 static void startXMLElement(void *inUserData,
00102 const char *inElementName,
00103 const char **inAttributes);
00105 static void endXMLElement(void *inUserData,
00106 const char *inElementName);
00107 };
00108 #endif