GrantleeTheme

grantleeki18nlocalizer.h
1 /*
2  * Copyright (C) 2015 Daniel Vr├ítil <[email protected]>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  */
19 
20 #ifndef GRANTLEEKI18NLOCALIZER_H
21 #define GRANTLEEKI18NLOCALIZER_H
22 
23 #include "grantleetheme_export.h"
24 #include <grantlee/qtlocalizer.h>
25 
26 #include <QLocale>
27 #include <QVariantHash>
28 
29 class KLocalizedString;
30 namespace GrantleeTheme {
34 class GRANTLEETHEME_EXPORT GrantleeKi18nLocalizer : public Grantlee::QtLocalizer
35 {
36 public:
37  explicit GrantleeKi18nLocalizer();
38  ~GrantleeKi18nLocalizer() override;
39 
40  // Only reimplement string localization to use KLocalizedString instead of
41  // tr(), the remaining methods use QLocale internally, so we can reuse them
42  Q_REQUIRED_RESULT QString localizeContextString(const QString &string, const QString &context, const QVariantList &arguments) const override;
43  Q_REQUIRED_RESULT QString localizeString(const QString &string, const QVariantList &arguments) const override;
44  Q_REQUIRED_RESULT QString localizePluralContextString(const QString &string, const QString &pluralForm, const QString &context, const QVariantList &arguments) const override;
45  Q_REQUIRED_RESULT QString localizePluralString(const QString &string, const QString &pluralForm, const QVariantList &arguments) const override;
46 
47  // Only exception, Grantlee's implementation is not using QLocale for this
48  // for some reason
49  Q_REQUIRED_RESULT QString localizeMonetaryValue(qreal value, const QString &currentCode) const override;
50 
51  Q_REQUIRED_RESULT QString currentLocale() const override;
52 
53  void setApplicationDomain(const QByteArray &domain);
54 private:
55  QString processArguments(const KLocalizedString &str, const QVariantList &arguments) const;
56  QByteArray mApplicationDomain;
57 };
58 }
59 
60 #endif // GRANTLEEKI18NLOCALIZER_H
The GrantleeKi18nLocalizer class.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed May 27 2020 22:46:09 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.