Kross

translation.h
1 /***************************************************************************
2  * translation.h
3  * This file is part of the KDE project
4  * copyright (C)2008 by Dag Andersen <[email protected]>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  * You should have received a copy of the GNU Library General Public License
15  * along with this program; see the file COPYING. If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  ***************************************************************************/
19 
20 #ifndef KROSS_TRANSLATION_H
21 #define KROSS_TRANSLATION_H
22 
23 #include <QObject>
24 #include <QVariantList>
25 
26 class QString;
27 
28 class KLocalizedString;
29 
30 namespace Kross
31 {
32 
33 /**
34  * The TranslationModule provides access to KDE translation and internationalization facilities.
35  *
36  * Example (in Python) :
37  * \code
38  * import Kross
39  * t = Kross.module("kdetranslation")
40  * print t.i18n("This string can be translated")
41  * print t.i18ncp("Plural example", "%1 file not deleted %2", "%1 files not deleted %2", 3, [t.i18n("yesterday")])
42  * \endcode
43  */
45 {
46  Q_OBJECT
47 
48 public:
49  explicit TranslationModule();
50  ~TranslationModule() override;
51 
52 public Q_SLOTS:
53  /// Creates localized string from a given @p text. Substitute @p arguments (may be empty)
54  QString i18n(const QString &text, const QVariantList &arguments = QVariantList()) const;
55  /// Creates localized string from a given @p text, with added context. Substitute @p arguments (may be empty)
56  QString i18nc(const QString &context, const QString &text, const QVariantList &arguments = QVariantList()) const;
57  /// Creates localized string from a given @p plural and @p singular form dependent on @p number. Substitute @p arguments (may be empty)
58  QString i18np(const QString &singular, const QString &plural, int number, const QVariantList &arguments = QVariantList()) const;
59  /// Creates localized string from a given @p plural and @p singular form dependent on @p number, with added context. Substitute @p arguments (may be empty)
60  QString i18ncp(const QString &context, const QString &singular, const QString &plural, int number, const QVariantList &arguments = QVariantList()) const;
61 
62 protected:
63  KLocalizedString substituteArguments(const KLocalizedString &kls, const QVariantList &arguments, int max = 99) const;
64 
65 private:
66  /// \internal d-pointer class.
67  class Private;
68  /// \internal d-pointer instance.
69  Private *const d;
70 };
71 }
72 
73 #endif
74 
Definition: action.cpp:36
QString i18ncp(const QString &context, const QString &singular, const QString &plural, int number, const QVariantList &arguments=QVariantList()) const
Creates localized string from a given plural and singular form dependent on number, with added context. Substitute arguments (may be empty)
Definition: translation.cpp:98
Q_OBJECTQ_OBJECT
QString i18np(const QString &singular, const QString &plural, int number, const QVariantList &arguments=QVariantList()) const
Creates localized string from a given plural and singular form dependent on number. Substitute arguments (may be empty)
Definition: translation.cpp:92
QString i18n(const QString &text, const QVariantList &arguments=QVariantList()) const
Creates localized string from a given text. Substitute arguments (may be empty)
Definition: translation.cpp:80
QString i18nc(const QString &context, const QString &text, const QVariantList &arguments=QVariantList()) const
Creates localized string from a given text, with added context. Substitute arguments (may be empty) ...
Definition: translation.cpp:86
The TranslationModule provides access to KDE translation and internationalization facilities...
Definition: translation.h:44
Q_SLOTSQ_SLOTS
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu Oct 21 2021 23:01:08 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.