System documentation of the GNU Image-Finding Tool

CI18nTranslator.h

00001 // -*- mode: c++ -*-
00002 #ifndef _CI18NTRANSLATOR
00003 #define _CI18NTRANSLATOR
00004 /* -*- mode: c++ -*- 
00005 */
00006 /* 
00007 
00008     GIFT, a flexible content based image retrieval system.
00009     Copyright (C) 1998, 1999, 2000, 2001, 2002, CUI University of Geneva
00010 
00011      Copyright (C) 2003, 2004 Bayreuth University
00012       2005 Bamberg University
00013     This program is free software; you can redistribute it and/or modify
00014     it under the terms of the GNU General Public License as published by
00015     the Free Software Foundation; either version 2 of the License, or
00016     (at your option) any later version.
00017 
00018     This program is distributed in the hope that it will be useful,
00019     but WITHOUT ANY WARRANTY; without even the implied warranty of
00020     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021     GNU General Public License for more details.
00022 
00023     You should have received a copy of the GNU General Public License
00024     along with this program; if not, write to the Free Software
00025     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026 
00027 */
00028 #include <map>
00029 #include <string>
00030 #include "libMRML/include/CXMLElement.h"
00031 #include <expat.h>
00032 //#include "expat/xmlparse/xmlparse.h"
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 CI18nTranslator::startXMLElement(void *inUserData, 
00102                                                const char *inElementName, 
00103                                                const char **inAttributes);
00105   static void CI18nTranslator::endXMLElement(void *inUserData, 
00106                                              const char *inElementName);
00107 };
00108 #endif

Need for discussion? Want to contribute? Contact
help-gift@gnu.org Generated using Doxygen