Grantlee 0.1.9
templates/lib/qtlocalizer.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_QTLOCALIZER_P_H
00022 #define GRANTLEE_QTLOCALIZER_P_H
00023 
00024 #include "abstractlocalizer.h"
00025 
00026 class QTranslator;
00027 
00028 namespace Grantlee
00029 {
00030 
00031 class QtLocalizerPrivate;
00032 
00055 class GRANTLEE_CORE_EXPORT QtLocalizer : public AbstractLocalizer
00056 {
00057 public:
00058 #ifndef Q_QDOC
00059   typedef QSharedPointer<QtLocalizer> Ptr;
00060 #endif
00061 
00064   QtLocalizer( const QLocale &locale = QLocale::system() );
00065 
00069   virtual ~QtLocalizer();
00070 
00074   void setAppTranslatorPath( const QString &path );
00075 
00080   void setAppTranslatorPrefix( const QString &prefix );
00081 
00094   void installTranslator( QTranslator *translator, const QString &localeName = QLocale::system().name() );
00095 
00096   virtual QString currentLocale() const;
00097   virtual void pushLocale( const QString &localeName );
00098   virtual void popLocale();
00099   virtual void loadCatalog( const QString &path, const QString &catalog );
00100   virtual void unloadCatalog( const QString &catalog );
00101 
00102   virtual QString localizeNumber( int number ) const;
00103   virtual QString localizeNumber( qreal number ) const;
00104   virtual QString localizeMonetaryValue( qreal value, const QString &currencyCode = QString() ) const;
00105   virtual QString localizeDate( const QDate &date, QLocale::FormatType formatType = QLocale::ShortFormat ) const;
00106   virtual QString localizeTime( const QTime &time, QLocale::FormatType formatType = QLocale::ShortFormat ) const;
00107   virtual QString localizeDateTime( const QDateTime& dateTime, QLocale::FormatType formatType = QLocale::ShortFormat ) const;
00108   virtual QString localizeString( const QString& string, const QVariantList &arguments = QVariantList() ) const;
00109   virtual QString localizeContextString( const QString& string, const QString& context, const QVariantList &arguments = QVariantList() ) const;
00110   virtual QString localizePluralContextString( const QString& string, const QString& pluralForm, const QString& context, const QVariantList &arguments = QVariantList() ) const;
00111   virtual QString localizePluralString( const QString& string, const QString& pluralForm, const QVariantList &arguments = QVariantList() ) const;
00112 
00113 private:
00114   Q_DECLARE_PRIVATE( QtLocalizer )
00115   Q_DISABLE_COPY( QtLocalizer )
00116   QtLocalizerPrivate * const d_ptr;
00117 };
00118 
00119 }
00120 
00121 #endif