| 1 | // Copyright (C) 2020 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QTRANSLATOR_H |
| 5 | #define QTRANSLATOR_H |
| 6 | |
| 7 | #include <QtCore/qobject.h> |
| 8 | #include <QtCore/qbytearray.h> |
| 9 | |
| 10 | QT_BEGIN_NAMESPACE |
| 11 | |
| 12 | |
| 13 | #ifndef QT_NO_TRANSLATION |
| 14 | |
| 15 | class QLocale; |
| 16 | class QTranslatorPrivate; |
| 17 | |
| 18 | class Q_CORE_EXPORT QTranslator : public QObject |
| 19 | { |
| 20 | Q_OBJECT |
| 21 | public: |
| 22 | explicit QTranslator(QObject *parent = nullptr); |
| 23 | ~QTranslator(); |
| 24 | |
| 25 | virtual QString translate(const char *context, const char *sourceText, |
| 26 | const char *disambiguation = nullptr, int n = -1) const; |
| 27 | |
| 28 | virtual bool isEmpty() const; |
| 29 | |
| 30 | QString language() const; |
| 31 | QString filePath() const; |
| 32 | |
| 33 | [[nodiscard]] bool load(const QString & filename, |
| 34 | const QString & directory = QString(), |
| 35 | const QString & search_delimiters = QString(), |
| 36 | const QString & suffix = QString()); |
| 37 | [[nodiscard]] bool load(const QLocale & locale, |
| 38 | const QString & filename, |
| 39 | const QString & prefix = QString(), |
| 40 | const QString & directory = QString(), |
| 41 | const QString & suffix = QString()); |
| 42 | [[nodiscard]] bool load(const uchar *data, int len, |
| 43 | const QString &directory = QString()); |
| 44 | |
| 45 | private: |
| 46 | Q_DISABLE_COPY(QTranslator) |
| 47 | Q_DECLARE_PRIVATE(QTranslator) |
| 48 | }; |
| 49 | |
| 50 | #endif // QT_NO_TRANSLATION |
| 51 | |
| 52 | QT_END_NAMESPACE |
| 53 | |
| 54 | #endif // QTRANSLATOR_H |
| 55 | |