Grantlee  0.4.0
abstractlocalizer.h
1 /*
2  This file is part of the Grantlee template system.
3 
4  Copyright (c) 2010 Stephen Kelly <steveire@gmail.com>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either version
9  2.1 of the Licence, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public
17  License along with this library. If not, see <http://www.gnu.org/licenses/>.
18 
19 */
20 
21 #ifndef GRANTLEE_ABSTRACTLOCALIZER_H
22 #define GRANTLEE_ABSTRACTLOCALIZER_H
23 
24 #include "grantlee_core_export.h"
25 
26 #include <QtCore/QLocale>
27 #include <QtCore/QSharedPointer>
28 #include <QtCore/QVariantList>
29 
30 class QDateTime;
31 
32 namespace Grantlee
33 {
34 
41 class GRANTLEE_CORE_EXPORT AbstractLocalizer
42 {
43 public:
47  typedef QSharedPointer<AbstractLocalizer> Ptr;
48 
53 
57  virtual ~AbstractLocalizer();
58 
64  virtual QString localize( const QVariant &variant ) const;
65 
69  virtual QString currentLocale() const = 0;
70 
74  virtual void pushLocale( const QString &localeName ) = 0;
75 
79  virtual void popLocale() = 0;
80 
84  virtual void loadCatalog( const QString &path, const QString &catalog ) = 0;
85 
89  virtual void unloadCatalog( const QString &catalog ) = 0;
90 
94  virtual QString localizeNumber( int number ) const = 0;
95 
99  virtual QString localizeNumber( qreal number ) const = 0;
100 
104  virtual QString localizeMonetaryValue( qreal value, const QString &currencyCode = QString() ) const = 0;
105 
109  virtual QString localizeDate( const QDate &date, QLocale::FormatType formatType = QLocale::ShortFormat ) const = 0;
110 
114  virtual QString localizeTime( const QTime &time, QLocale::FormatType formatType = QLocale::ShortFormat ) const = 0;
115 
119  virtual QString localizeDateTime( const QDateTime &dateTime, QLocale::FormatType formatType = QLocale::ShortFormat ) const = 0;
120 
124  virtual QString localizeString( const QString &string, const QVariantList &arguments = QVariantList() ) const = 0;
125 
129  virtual QString localizeContextString( const QString &string, const QString &context, const QVariantList &arguments = QVariantList() ) const = 0;
130 
134  virtual QString localizePluralString( const QString &string, const QString& pluralForm, const QVariantList &arguments = QVariantList() ) const = 0;
135 
139  virtual QString localizePluralContextString( const QString &string, const QString& pluralForm, const QString &context, const QVariantList &arguments = QVariantList() ) const = 0;
140 private:
141  Q_DISABLE_COPY( AbstractLocalizer )
142 };
143 
144 }
145 
146 #endif
147 
Interface for implementing an internationalization system.
QSharedPointer< AbstractLocalizer > Ptr
The Grantlee namespace holds all public Grantlee API.
Definition: Mainpage.dox:7