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