System documentation of the GNU Image-Finding Tool

Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

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     This program is free software; you can redistribute it and/or modify
00012     it under the terms of the GNU General Public License as published by
00013     the Free Software Foundation; either version 2 of the License, or
00014     (at your option) any later version.
00015 
00016     This program is distributed in the hope that it will be useful,
00017     but WITHOUT ANY WARRANTY; without even the implied warranty of
00018     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019     GNU General Public License for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with this program; if not, write to the Free Software
00023     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00024 
00025 */
00026 #include <map>
00027 #include <string>
00028 #include "libMRML/include/CXMLElement.h"
00029 #include <expat.h>
00030 //#include "expat/xmlparse/xmlparse.h"
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

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