Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
proxytranslator.h
Go to the documentation of this file.
1// Copyright (C) 2021 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 PROXYTRANSLATOR_H
5#define PROXYTRANSLATOR_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <private/qqmldebugserviceinterfaces_p.h>
19#include <private/qqmlglobal_p.h>
20
21#include <QtCore/qstring.h>
22#include <QtCore/qurl.h>
23#include <QtCore/qtranslator.h>
24
25#include <memory>
26
28
30{
32public:
33 QString translate(const char *context, const char *sourceText, const char *disambiguation, int n) const override;
34 bool isEmpty() const override;
35
37 void setLanguage(const QUrl &context, const QLocale &locale);
40
41 bool hasTranslation(const TranslationBindingInformation &translationBindingInformation) const;
42 static QString
43 translationFromInformation(const TranslationBindingInformation &translationBindingInformation);
44 static QQmlSourceLocation sourceLocationFromInformation(const TranslationBindingInformation &translationBindingInformation);
46 void languageChanged(const QLocale &locale);
47
48private:
49 void resetTranslationFound() const;
50 bool translationFound() const;
51 QList<QQmlEngine *> m_engines;
52 std::unique_ptr<QTranslator> m_qtTranslator;
53 std::unique_ptr<QTranslator> m_qmlTranslator;
54 bool m_enable = false;
55 QString m_currentUILanguages;
56 mutable bool m_translationFound = false;
57};
58
60
61#endif // PROXYTRANSLATOR_H
bool isEmpty() const override
Returns true if this translator is empty, otherwise returns false.
static QString translationFromInformation(const TranslationBindingInformation &translationBindingInformation)
void removeEngine(QQmlEngine *engine)
static QQmlSourceLocation sourceLocationFromInformation(const TranslationBindingInformation &translationBindingInformation)
void languageChanged(const QLocale &locale)
bool hasTranslation(const TranslationBindingInformation &translationBindingInformation) const
QString translate(const char *context, const char *sourceText, const char *disambiguation, int n) const override
Returns the translation for the key (context, sourceText, disambiguation).
void addEngine(QQmlEngine *engine)
void setLanguage(const QUrl &context, const QLocale &locale)
QString currentUILanguages() const
The QQmlEngine class provides an environment for instantiating QML components.
Definition qqmlengine.h:57
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qtranslator.h:19
\inmodule QtCore
Definition qurl.h:94
Combined button and popup list for selecting options.
static void * context
GLfloat n
#define Q_OBJECT
#define Q_SIGNALS
QJSEngine engine
[0]