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 <QMap>
10#include <QString>
11
12#ifndef LINGUIST_CONSOLE_APPLICATION
13# include <optional>
14#endif
15
16QT_BEGIN_NAMESPACE
17
18class Phrase;
20
21namespace Ui {
22class MainWindow;
23}
24
25struct Validator
26{
27
28 struct Checks
29 {
30 bool accelerator = true;
31 bool punctuation = true;
32 bool placeMarker = true;
34#ifndef LINGUIST_CONSOLE_APPLICATION
35 bool phraseMatch = true;
36#endif
37 };
38
48
50
51 static Validator fromSource(const QString &source, const Checks &checks,
52 const QLocale::Language &locale,
53 const QHash<QString, QList<Phrase *>> &phrases);
54
55 QMap<ErrorType, QString> validate(QStringList translations, const TranslatorMessage &msg,
56 const QLocale::Language &locale, QList<bool> countRefNeeds);
57
58private:
59 Validator() = default;
60 QMap<ErrorType, QString> validateTranslation(const QString &translation,
61 const QLocale::Language &locale, bool needsRef);
62 std::optional<bool> m_haveMnemonic;
63 std::optional<QString> m_leadingWhiteSpace;
64 std::optional<QString> m_trailingWhiteSpace;
65 std::optional<Ending> m_ending;
66 std::optional<QHash<int, int>> m_placeMarkerCounts;
67#ifndef LINGUIST_CONSOLE_APPLICATION
68 std::optional<QHash<QString, QStringList>> m_matchingPhraseTargets;
69#endif
70};
71
72QT_END_NAMESPACE
73
74#endif // VALIDATOR_H
bool surroundingWhiteSpace
Definition validator.h:33
static Validator fromSource(const QString &source, const Checks &checks, const QLocale::Language &locale, const QHash< QString, QList< Phrase * > > &phrases)
QMap< ErrorType, QString > validate(QStringList translations, const TranslatorMessage &msg, const QLocale::Language &locale, QList< bool > countRefNeeds)
@ PunctuationDiffers
Definition validator.h:43
@ PlaceMarkersDiffer
Definition validator.h:45
@ NumerusMarkerMissing
Definition validator.h:46
@ IgnoredPhrasebook
Definition validator.h:44
@ SuperfluousAccelerator
Definition validator.h:40
@ MissingAccelerator
Definition validator.h:41
@ SurroundingWhitespaceDiffers
Definition validator.h:42
@ End_Interrobang
Definition validator.h:49
@ End_Ellipsis
Definition validator.h:49
@ End_FullStop
Definition validator.h:49