KTextTemplate

abstractlocalizer.h
1/*
2 This file is part of the KTextTemplate library
3
4 SPDX-FileCopyrightText: 2010 Stephen Kelly <steveire@gmail.com>
5
6 SPDX-License-Identifier: LGPL-2.1-or-later
7
8*/
9
10#ifndef KTEXTTEMPLATE_ABSTRACTLOCALIZER_H
11#define KTEXTTEMPLATE_ABSTRACTLOCALIZER_H
12
13#include "ktexttemplate_export.h"
14
15#include <QLocale>
16#include <QSharedPointer>
17#include <QVariantList>
18
19class QDateTime;
20
21namespace KTextTemplate
22{
23
24/// @headerfile abstractlocalizer.h <KTextTemplate/AbstractLocalizer>
25
26/**
27 @brief Interface for implementing an internationalization system.
28
29 This class defines an interface for accessing an internationalization, such as
30 QLocale/QTranslator or gettext/KLocale.
31
32 @author Stephen Kelly <steveire@gmail.com>
33*/
34class KTEXTTEMPLATE_EXPORT AbstractLocalizer
35{
36public:
37 /**
38 Constructor
39 */
41
42 /**
43 Destructor
44 */
46
47 /**
48 Processes the data in @p variant into a localized string.
49
50 The base implementation can localize numbers, dates and times, and
51 strings.
52 */
53 virtual QString localize(const QVariant &variant) const;
54
55 /**
56 Returns the current locale as a string.
57 */
58 virtual QString currentLocale() const = 0;
59
60 /**
61 Makes this localizer use the locale specified by @p localeName for output.
62 */
63 virtual void pushLocale(const QString &localeName) = 0;
64
65 /**
66 Makes this localizer use the previous locale for output.
67 */
68 virtual void popLocale() = 0;
69
70 /**
71 Loads the @p catalog from @p path.
72 */
73 virtual void loadCatalog(const QString &path, const QString &catalog) = 0;
74
75 /**
76 Unloads the @p catalog
77 */
78 virtual void unloadCatalog(const QString &catalog) = 0;
79
80 /**
81 Localizes @p number
82 */
83 virtual QString localizeNumber(int number) const = 0;
84
85 /**
86 Localizes @p number
87 */
88 virtual QString localizeNumber(qreal number) const = 0;
89
90 /**
91 Localizes @p value as a monetary value in the currency specified by @p
92 currencyCode.
93 */
94 virtual QString localizeMonetaryValue(qreal value, const QString &currencyCode = {}) const = 0;
95
96 /**
97 Localizes @p date with the specified @p formatType
98 */
99 virtual QString localizeDate(const QDate &date, QLocale::FormatType formatType = QLocale::ShortFormat) const = 0;
100
101 /**
102 Localizes @p time with the specified @p formatType
103 */
104 virtual QString localizeTime(const QTime &time, QLocale::FormatType formatType = QLocale::ShortFormat) const = 0;
105
106 /**
107 Localizes @p dateTime with the specified @p formatType
108 */
109 virtual QString localizeDateTime(const QDateTime &dateTime, QLocale::FormatType formatType = QLocale::ShortFormat) const = 0;
110
111 /**
112 Localizes @p string with the specified @p arguments for substitution
113 */
114 virtual QString localizeString(const QString &string, const QVariantList &arguments = {}) const = 0;
115
116 /**
117 Localizes @p string, disambiguated by @p context with the specified @p
118 arguments for substitution
119 */
120 virtual QString localizeContextString(const QString &string, const QString &context, const QVariantList &arguments = {}) const = 0;
121
122 /**
123 Localizes @p string or its @p pluralForm with the specified @p arguments
124 for substitution
125 */
126 virtual QString localizePluralString(const QString &string, const QString &pluralForm, const QVariantList &arguments = {}) const = 0;
127
128 /**
129 Localizes @p string or its @p pluralForm, disambiguated by @p context with
130 the specified @p arguments for substitution
131 */
132 virtual QString
133 localizePluralContextString(const QString &string, const QString &pluralForm, const QString &context, const QVariantList &arguments = {}) const = 0;
134
135private:
136 Q_DISABLE_COPY(AbstractLocalizer)
137};
138}
139
140#endif
Interface for implementing an internationalization system.
virtual QString localizeDateTime(const QDateTime &dateTime, QLocale::FormatType formatType=QLocale::ShortFormat) const =0
Localizes dateTime with the specified formatType.
virtual QString localizeContextString(const QString &string, const QString &context, const QVariantList &arguments={}) const =0
Localizes string, disambiguated by context with the specified arguments for substitution.
virtual void unloadCatalog(const QString &catalog)=0
Unloads the catalog.
virtual QString localizeMonetaryValue(qreal value, const QString &currencyCode={}) const =0
Localizes value as a monetary value in the currency specified by currencyCode.
virtual ~AbstractLocalizer()
Destructor.
virtual QString localizePluralContextString(const QString &string, const QString &pluralForm, const QString &context, const QVariantList &arguments={}) const =0
Localizes string or its pluralForm, disambiguated by context with the specified arguments for substit...
virtual QString localizePluralString(const QString &string, const QString &pluralForm, const QVariantList &arguments={}) const =0
Localizes string or its pluralForm with the specified arguments for substitution.
virtual QString localizeNumber(int number) const =0
Localizes number.
virtual void loadCatalog(const QString &path, const QString &catalog)=0
Loads the catalog from path.
virtual QString localizeNumber(qreal number) const =0
Localizes number.
virtual void popLocale()=0
Makes this localizer use the previous locale for output.
virtual QString localizeTime(const QTime &time, QLocale::FormatType formatType=QLocale::ShortFormat) const =0
Localizes time with the specified formatType.
virtual QString localizeString(const QString &string, const QVariantList &arguments={}) const =0
Localizes string with the specified arguments for substitution.
virtual QString currentLocale() const =0
Returns the current locale as a string.
virtual void pushLocale(const QString &localeName)=0
Makes this localizer use the locale specified by localeName for output.
virtual QString localizeDate(const QDate &date, QLocale::FormatType formatType=QLocale::ShortFormat) const =0
Localizes date with the specified formatType.
The KTextTemplate namespace holds all public KTextTemplate API.
Definition Mainpage.dox:8
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:17:29 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.