GrantleeTheme

grantleeki18nlocalizer.h
1 /*
2  * SPDX-FileCopyrightText: 2015 Daniel Vr├ítil <[email protected]>
3  *
4  * SPDX-License-Identifier: LGPL-2.1-or-later
5  *
6  */
7 
8 #pragma once
9 #include "grantleetheme_export.h"
10 #include <QObject>
11 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
12 #include <grantlee/qtlocalizer.h>
13 #else
14 #include <KTextTemplate/qtlocalizer.h>
15 #endif
16 
17 #include <QLocale>
18 #include <QVariantHash>
19 
20 class KLocalizedString;
21 namespace GrantleeTheme
22 {
23 /**
24  * @brief The GrantleeKi18nLocalizer class
25  */
26 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
27 class GRANTLEETHEME_EXPORT GrantleeKi18nLocalizer : public Grantlee::QtLocalizer
28 #else
29 class GRANTLEETHEME_EXPORT GrantleeKi18nLocalizer : public KTextTemplate::QtLocalizer
30 #endif
31 {
32 public:
33  explicit GrantleeKi18nLocalizer();
34  ~GrantleeKi18nLocalizer() override;
35 
36  // Only reimplement string localization to use KLocalizedString instead of
37  // tr(), the remaining methods use QLocale internally, so we can reuse them
38  Q_REQUIRED_RESULT QString localizeContextString(const QString &string, const QString &context, const QVariantList &arguments) const override;
39  Q_REQUIRED_RESULT QString localizeString(const QString &string, const QVariantList &arguments) const override;
40  Q_REQUIRED_RESULT QString localizePluralContextString(const QString &string,
41  const QString &pluralForm,
42  const QString &context,
43  const QVariantList &arguments) const override;
44  Q_REQUIRED_RESULT QString localizePluralString(const QString &string, const QString &pluralForm, const QVariantList &arguments) const override;
45 
46  // Only exception, Grantlee's implementation is not using QLocale for this
47  // for some reason
48  Q_REQUIRED_RESULT QString localizeMonetaryValue(qreal value, const QString &currentCode) const override;
49 
50  Q_REQUIRED_RESULT QString currentLocale() const override;
51 
52  void setApplicationDomain(const QByteArray &domain);
53 
54 private:
55  QString processArguments(const KLocalizedString &str, const QVariantList &arguments) const;
56  QByteArray mApplicationDomain;
57 };
58 }
59 
The GrantleeKi18nLocalizer class.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Wed Sep 28 2022 04:06:59 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.