Grantlee  5.1.0
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 
00056 class GRANTLEE_TEMPLATES_EXPORT QtLocalizer : public AbstractLocalizer
00057 {
00058 public:
00062   QtLocalizer(const QLocale &locale = QLocale::system());
00063 
00067   ~QtLocalizer() override;
00068 
00072   void setAppTranslatorPath(const QString &path);
00073 
00080   void setAppTranslatorPrefix(const QString &prefix);
00081 
00094   void installTranslator(QTranslator *translator,
00095                          const QString &localeName = QLocale::system().name());
00096 
00097   QString currentLocale() const override;
00098   void pushLocale(const QString &localeName) override;
00099   void popLocale() override;
00100   void loadCatalog(const QString &path, const QString &catalog) override;
00101   void unloadCatalog(const QString &catalog) override;
00102 
00103   QString localizeNumber(int number) const override;
00104   QString localizeNumber(qreal number) const override;
00105   QString localizeMonetaryValue(qreal value, const QString &currencyCode
00106                                              = QString()) const override;
00107   QString localizeDate(const QDate &date,
00108                        QLocale::FormatType formatType
00109                        = QLocale::ShortFormat) const override;
00110   QString localizeTime(const QTime &time,
00111                        QLocale::FormatType formatType
00112                        = QLocale::ShortFormat) const override;
00113   QString localizeDateTime(const QDateTime &dateTime,
00114                            QLocale::FormatType formatType
00115                            = QLocale::ShortFormat) const override;
00116   QString localizeString(const QString &string,
00117                          const QVariantList &arguments
00118                          = QVariantList()) const override;
00119   QString localizeContextString(const QString &string, const QString &context,
00120                                 const QVariantList &arguments
00121                                 = QVariantList()) const override;
00122   QString localizePluralContextString(const QString &string,
00123                                       const QString &pluralForm,
00124                                       const QString &context,
00125                                       const QVariantList &arguments
00126                                       = QVariantList()) const override;
00127   QString localizePluralString(const QString &string, const QString &pluralForm,
00128                                const QVariantList &arguments
00129                                = QVariantList()) const override;
00130 
00131 private:
00132   Q_DECLARE_PRIVATE(QtLocalizer)
00133   Q_DISABLE_COPY(QtLocalizer)
00134   QtLocalizerPrivate *const d_ptr;
00135 };
00136 }
00137 
00138 #endif