Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
validator.h
Go to the documentation of this file.
1// Copyright (C) 2025 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#ifndef VALIDATOR_H
5#define VALIDATOR_H
6
7#include <QHash>
8#include <QLocale>
9#include <QString>
10
11#ifndef LINGUIST_CONSOLE_APPLICATION
12# include <optional>
13#endif
14
15QT_BEGIN_NAMESPACE
16
17class Phrase;
19
20namespace Ui {
21class MainWindow;
22}
23
24struct Validator
25{
26
27 struct Checks
28 {
29 bool accelerator = true;
30 bool punctuation = true;
31 bool placeMarker = true;
33#ifndef LINGUIST_CONSOLE_APPLICATION
34 bool phraseMatch = true;
35#endif
36 };
37
47
49
55
56 static Validator fromSource(const QString &source, const Checks &checks,
57 const QLocale::Language &locale,
58 const QHash<QString, QList<Phrase *>> &phrases);
59
60 QList<Error> validate(QStringList translations, const TranslatorMessage &msg,
61 const QLocale::Language &locale, QList<bool> countRefNeeds);
62
63private:
64 Validator() = default;
65 QList<Error> validateTranslation(const QString &translation, const QLocale::Language &locale,
66 bool needsRef);
67 std::optional<bool> m_haveMnemonic;
68 std::optional<QString> m_leadingWhiteSpace;
69 std::optional<QString> m_trailingWhiteSpace;
70 std::optional<Ending> m_ending;
71 std::optional<QHash<int, int>> m_placeMarkerCounts;
72#ifndef LINGUIST_CONSOLE_APPLICATION
73 std::optional<QHash<QString, QStringList>> m_matchingPhraseTargets;
74#endif
75};
76
77QT_END_NAMESPACE
78
79#endif // VALIDATOR_H
bool surroundingWhiteSpace
Definition validator.h:32
ErrorType type
Definition validator.h:52
QString message
Definition validator.h:53
static Validator fromSource(const QString &source, const Checks &checks, const QLocale::Language &locale, const QHash< QString, QList< Phrase * > > &phrases)
QList< Error > validate(QStringList translations, const TranslatorMessage &msg, const QLocale::Language &locale, QList< bool > countRefNeeds)
@ PunctuationDiffers
Definition validator.h:42
@ PlaceMarkersDiffer
Definition validator.h:44
@ NumerusMarkerMissing
Definition validator.h:45
@ IgnoredPhrasebook
Definition validator.h:43
@ SuperfluousAccelerator
Definition validator.h:39
@ MissingAccelerator
Definition validator.h:40
@ SurroundingWhitespaceDiffers
Definition validator.h:41
@ End_Interrobang
Definition validator.h:48
@ End_Ellipsis
Definition validator.h:48
@ End_FullStop
Definition validator.h:48