Grantlee  5.1.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_templates_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_TEMPLATES_EXPORT AbstractLocalizer
00042 {
00043 public:
00047   AbstractLocalizer();
00048 
00052   virtual ~AbstractLocalizer();
00053 
00060   virtual QString localize(const QVariant &variant) const;
00061 
00065   virtual QString currentLocale() const = 0;
00066 
00070   virtual void pushLocale(const QString &localeName) = 0;
00071 
00075   virtual void popLocale() = 0;
00076 
00080   virtual void loadCatalog(const QString &path, const QString &catalog) = 0;
00081 
00085   virtual void unloadCatalog(const QString &catalog) = 0;
00086 
00090   virtual QString localizeNumber(int number) const = 0;
00091 
00095   virtual QString localizeNumber(qreal number) const = 0;
00096 
00101   virtual QString localizeMonetaryValue(qreal value, const QString &currencyCode
00102                                                      = QString()) const = 0;
00103 
00107   virtual QString localizeDate(const QDate &date,
00108                                QLocale::FormatType formatType
00109                                = QLocale::ShortFormat) const = 0;
00110 
00114   virtual QString localizeTime(const QTime &time,
00115                                QLocale::FormatType formatType
00116                                = QLocale::ShortFormat) const = 0;
00117 
00121   virtual QString localizeDateTime(const QDateTime &dateTime,
00122                                    QLocale::FormatType formatType
00123                                    = QLocale::ShortFormat) const = 0;
00124 
00128   virtual QString localizeString(const QString &string,
00129                                  const QVariantList &arguments
00130                                  = QVariantList()) const = 0;
00131 
00136   virtual QString localizeContextString(const QString &string,
00137                                         const QString &context,
00138                                         const QVariantList &arguments
00139                                         = QVariantList()) const = 0;
00140 
00146   virtual QString localizePluralString(const QString &string,
00147                                        const QString &pluralForm,
00148                                        const QVariantList &arguments
00149                                        = QVariantList()) const = 0;
00150 
00155   virtual QString localizePluralContextString(const QString &string,
00156                                               const QString &pluralForm,
00157                                               const QString &context,
00158                                               const QVariantList &arguments
00159                                               = QVariantList()) const = 0;
00160 
00161 private:
00162   Q_DISABLE_COPY(AbstractLocalizer)
00163 };
00164 }
00165 
00166 #endif