ximol/translation.hpp

Go to the documentation of this file.
00001 /*****************************************************************************\
00002  *                                                                           *
00003  * library XiMoL                                                             *
00004  * Copyright (C) 2002, 2003, 2004 Florent Tournois                           *
00005  *                                                                           *
00006  * This library is free software; you can redistribute it and/or             *
00007  * modify it under the terms of the GNU Lesser General Public                *
00008  * License as published by the Free Software Foundation; either              *
00009  * version 2.1 of the License, or (at your option) any later version.        *
00010  *                                                                           *
00011  * This library is distributed in the hope that it will be useful,           *
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of            *
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
00014  * Lesser General Public License for more details.                           *
00015  *                                                                           *
00016  * You should have received a copy of the GNU Lesser General Public          *
00017  * License along with this library; if not, write to the Free Software       *
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA   *
00019  *                                                                           *
00020 \*****************************************************************************/
00021 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00022 /** \file 
00023         \brief gettext wrapper for the library.
00024         
00025         \warning This file must be include only in cpp file.
00026   
00027         \author Tournois Florent
00028         \version 1.0
00029 
00030     $Id: translation.hpp,v 1.14 2004/03/03 22:05:30 tournois Exp $
00031     $Log: translation.hpp,v $
00032     Revision 1.14  2004/03/03 22:05:30  tournois
00033     Add a short roadmap.
00034     Add BOOST_NO_STD_WSTRING for gcc.
00035 
00036     Revision 1.13  2004/02/25 15:57:06  tournois
00037     no message
00038 
00039     Revision 1.12  2004/02/22 10:27:33  tournois
00040     Add some doc.
00041 
00042     Revision 1.11  2004/02/22 09:54:19  tournois
00043     Change years on the copyright.
00044 
00045     Revision 1.10  2004/02/19 18:59:27  tournois
00046     attribute doc
00047 
00048     Revision 1.9  2003/12/03 12:59:34  hfp
00049     include dependencies and type forwarding
00050 
00051     Revision 1.8  2003/11/18 18:54:51  tournois
00052     Add str_cast and drop the transformation.hpp file.
00053 
00054     Revision 1.7  2003/11/17 22:06:01  tournois
00055     Add traits for relation stream--object.
00056     Change cast.
00057 
00058     Revision 1.6  2003/11/16 18:15:54  tournois
00059     Write operator>> et operator<< for (wostream and char,string) and (ostream and wchar_t, wstring).
00060 
00061     Revision 1.5  2003/11/16 13:25:25  tournois
00062     Change the error to use wide string.
00063     Change the translation to use wide string.
00064 
00065     Revision 1.4  2003/11/16 11:03:23  tournois
00066     no message
00067 
00068     Revision 1.3  2003/11/02 19:23:01  tournois
00069     Go to the boost coding standard.
00070     Change all name to lower case.
00071 
00072     Revision 1.2  2003/09/24 08:28:17  tournois
00073     Create the namespace Encoders, Parser, Xml
00074     Change the library organization.
00075     add VC7.1 project for this organization.
00076 
00077   */
00078 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00079 #ifndef XIMOL_TRANSLATION_HPP_
00080 #define XIMOL_TRANSLATION_HPP_
00081 
00082 #include <ximol/namespace_defs.hpp>
00083 #include <ximol/export_defs.hpp>
00084 #include <ximol/str_cast.hpp>
00085 #include <string>
00086 #include <list>
00087 
00088 XIMOL_BEGIN_NAMESPACE
00089 
00090 //------------------------------------------------------------------------------
00091 /** base function for the translation.
00092  *  @param x: the input string in english.
00093  *  @return the output string in other langage.
00094  */
00095 //------------------------------------------------------------------------------
00096 XIMOL_EXPORT
00097 const wchar_t * translate(const wchar_t * x);
00098 
00099 //------------------------------------------------------------------------------
00100 /** Translate the base string and place arguments.
00101  *  @param x: the input string in english.
00102  *  @param args: arguments serialized in wstring.
00103  *  @return the output string in other langage.
00104  */
00105 //------------------------------------------------------------------------------
00106 XIMOL_EXPORT
00107 std::wstring translate(const std::wstring & x, const std::list<std::wstring> & args);
00108 
00109 //------------------------------------------------------------------------------
00110 /// Function for the translation with 0 argument.
00111 //------------------------------------------------------------------------------
00112 XIMOL_EXPORT
00113 std::wstring _(const std::wstring& x);
00114 
00115 //------------------------------------------------------------------------------
00116 /** Function for the translation with 1 argument.
00117  *  %o to print an object.
00118  *  %% to print %
00119  */
00120 //------------------------------------------------------------------------------
00121 template < typename T1>
00122 std::wstring _(const std::wstring& x_start, const T1& t1)
00123 {
00124     std::list<std::wstring> args;
00125     args.push_back(str< ::std::wstring>::cast(t1));
00126     return translate(x_start,args);
00127 };
00128 
00129 //------------------------------------------------------------------------------
00130 /** Function for the translation with 2 arguments.
00131  *  %o to print an object.
00132  *  %% to print %
00133  */
00134 //------------------------------------------------------------------------------
00135 template < typename T1, typename T2>
00136 std::wstring _(const std::wstring& x_start, const T1& t1, const T2& t2)
00137 {
00138     std::list<std::wstring> args;
00139     args.push_back(str< ::std::wstring>::cast(t1));
00140     args.push_back(str< ::std::wstring>::cast(t2));
00141     return translate(x_start,args);
00142 };
00143 
00144 //------------------------------------------------------------------------------
00145 /** Function for the translation with 3 arguments.
00146  *  %o to print an object.
00147  *  %% to print %
00148  */
00149 //------------------------------------------------------------------------------
00150 template < typename T1, typename T2, typename T3>
00151 std::wstring _(const std::wstring& x_start, const T1& t1, const T2& t2, const T3& t3)
00152 {
00153     std::list<std::wstring> args;
00154     args.push_back(str< ::std::wstring>::cast(t1));
00155     args.push_back(str< ::std::wstring>::cast(t2));
00156     args.push_back(str< ::std::wstring>::cast(t3));
00157     return translate(x_start,args);
00158 };
00159 
00160 //------------------------------------------------------------------------------
00161 /** Function for the translation with 4 arguments.
00162  *  %o to print an object.
00163  *  %% to print %
00164  */
00165 //------------------------------------------------------------------------------
00166 template < typename T1, typename T2, typename T3, typename T4>
00167 std::wstring _(const std::wstring& x_start, const T1& t1, const T2& t2, const T3& t3, const T4& t4)
00168 {
00169     std::list<std::wstring> args;
00170     args.push_back(str< ::std::wstring>::cast(t1));
00171     args.push_back(str< ::std::wstring>::cast(t2));
00172     args.push_back(str< ::std::wstring>::cast(t3));
00173     args.push_back(str< ::std::wstring>::cast(t4));
00174     return translate(x_start,args);
00175 };
00176 
00177 XIMOL_END_NAMESPACE
00178 
00179 #endif // #ifndef XIMOL_TRANSLATION_HPP_


Donate to the XiMoL project SourceForge.net Logo If you have any questions about XiMoL, you could write to tournois@users.sourceforge.net.