Grantlee  0.2.0
templates/lib/abstractlocalizer.h
00001 /*
00002   This file is part of the Grantlee template system.
00003 
00004   Copyright (c) 2010 Stephen Kelly <steveire@gmail.com>
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 version
00009   2.1 of the Licence, 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, see <http://www.gnu.org/licenses/>.
00018 
00019 */
00020 
00021 #ifndef GRANTLEE_ABSTRACTLOCALIZER_H
00022 #define GRANTLEE_ABSTRACTLOCALIZER_H
00023 
00024 #include "grantlee_core_export.h"
00025 
00026 #include <QtCore/QLocale>
00027 #include <QtCore/QSharedPointer>
00028 #include <QtCore/QVariantList>
00029 
00030 class QDateTime;
00031 
00032 namespace Grantlee
00033 {
00034 
00041 class GRANTLEE_CORE_EXPORT AbstractLocalizer
00042 {
00043 public:
00047   typedef QSharedPointer<AbstractLocalizer> Ptr;
00048 
00052   AbstractLocalizer();
00053 
00057   virtual ~AbstractLocalizer();
00058 
00064   virtual QString localize( const QVariant &variant ) const;
00065 
00069   virtual QString currentLocale() const = 0;
00070 
00074   virtual void pushLocale( const QString &localeName ) = 0;
00075 
00079   virtual void popLocale() = 0;
00080 
00084   virtual void loadCatalog( const QString &path, const QString &catalog ) = 0;
00085 
00089   virtual void unloadCatalog( const QString &catalog ) = 0;
00090 
00094   virtual QString localizeNumber( int number ) const = 0;
00095 
00099   virtual QString localizeNumber( qreal number ) const = 0;
00100 
00104   virtual QString localizeMonetaryValue( qreal value, const QString &currencyCode = QString() ) const = 0;
00105 
00109   virtual QString localizeDate( const QDate &date, QLocale::FormatType formatType = QLocale::ShortFormat ) const = 0;
00110 
00114   virtual QString localizeTime( const QTime &time, QLocale::FormatType formatType = QLocale::ShortFormat ) const = 0;
00115 
00119   virtual QString localizeDateTime( const QDateTime &dateTime, QLocale::FormatType formatType = QLocale::ShortFormat ) const = 0;
00120 
00124   virtual QString localizeString( const QString &string, const QVariantList &arguments = QVariantList() ) const = 0;
00125 
00129   virtual QString localizeContextString( const QString &string, const QString &context, const QVariantList &arguments = QVariantList() ) const = 0;
00130 
00134   virtual QString localizePluralString( const QString &string, const QString& pluralForm, const QVariantList &arguments = QVariantList() ) const = 0;
00135 
00139   virtual QString localizePluralContextString( const QString &string, const QString& pluralForm, const QString &context, const QVariantList &arguments = QVariantList() ) const = 0;
00140 private:
00141   Q_DISABLE_COPY( AbstractLocalizer )
00142 };
00143 
00144 }
00145 
00146 #endif
00147