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
lupdate.h
Go to the documentation of this file.
1// Copyright (C) 2016 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 LUPDATE_H
5#define LUPDATE_H
6
7#include <QtCore/qtcore-config.h>
8#include <QtTools/private/qttools-config_p.h>
9
10#include <QtCore/QList>
11#include <QtCore/QHash>
12#include <QtCore/QCoreApplication>
13#include <QtCore/QString>
14#include <QtCore/QStringList>
15#include <QtCore/QTranslator>
16
17QT_BEGIN_NAMESPACE
18
19class ConversionData;
20class Translator;
22
37
38Q_DECLARE_FLAGS(UpdateOptions, UpdateOption)
39Q_DECLARE_OPERATORS_FOR_FLAGS(UpdateOptions)
40
41Translator merge(
42 const Translator &tor, const Translator &virginTor, const QList<Translator> &aliens,
43 UpdateOptions options, QString &err);
44
45void loadCPP(Translator &translator, const QStringList &filenames, ConversionData &cd);
46bool loadJava(Translator &translator, const QString &filename, ConversionData &cd);
47bool loadPython(Translator &translator, const QString &fileName, ConversionData &cd);
48bool loadUI(Translator &translator, const QString &filename, ConversionData &cd);
49
50#ifndef QT_NO_QML
51bool loadQScript(Translator &translator, const QString &filename, ConversionData &cd);
52bool loadJSModule(Translator &translator, const QString &filename, ConversionData &cd);
53bool loadQml(Translator &translator, const QString &filename, ConversionData &cd);
54#endif
55
56#define LUPDATE_FOR_EACH_TR_FUNCTION(UNARY_MACRO)
57 /* from cpp.cpp */
58 UNARY_MACRO(Q_DECLARE_TR_FUNCTIONS)
59 UNARY_MACRO(QT_TR_N_NOOP)
60 UNARY_MACRO(QT_TRID_N_NOOP)
61 UNARY_MACRO(QT_TRANSLATE_N_NOOP)
62 UNARY_MACRO(QT_TRANSLATE_N_NOOP3)
63 UNARY_MACRO(QT_TR_NOOP)
64 UNARY_MACRO(QT_TRID_NOOP)
65 UNARY_MACRO(QT_TRANSLATE_NOOP)
66 UNARY_MACRO(QT_TRANSLATE_NOOP3)
67 UNARY_MACRO(QT_TR_NOOP_UTF8)
68 UNARY_MACRO(QT_TRANSLATE_NOOP_UTF8)
69 UNARY_MACRO(QT_TRANSLATE_NOOP3_UTF8)
70 UNARY_MACRO(findMessage) /* QTranslator::findMessage() has the same parameters as QApplication::translate() */
71 UNARY_MACRO(qtTrId)
72 UNARY_MACRO(tr)
73 UNARY_MACRO(trUtf8)
74 UNARY_MACRO(translate)
75 /* from qdeclarative.cpp: */
76 UNARY_MACRO(qsTr)
77 UNARY_MACRO(qsTrId)
78 UNARY_MACRO(qsTranslate)
79 /*end*/
80
82{
83public:
84 static QString transcode(const QString &str);
85};
86
88public:
91
93 // need to uglify names b/c most of the names are themselves macros:
94#define MAKE_ENTRY(F) Function_##F,
96#undef MAKE_ENTRY
98 };
99
101
103
104 int trFunctionByName(const QString &trFunctionName) const;
105
106 void modifyAlias(int trFunction, const QString &alias, Operation op);
107
108 bool isAliasFor(const QString &identifier, TrFunction trFunction) const
109 { return m_trFunctionAliases[trFunction].contains(identifier); }
110
112 QStringList listAliases() const;
113
115
116private:
117 void ensureTrFunctionHashUpdated() const;
118
119private:
120 QStringList m_trFunctionAliases[NumTrFunctions];
121 mutable NameToTrFunctionMap m_nameToTrFunctionMap;
122};
123
124QT_END_NAMESPACE
125
126extern QT_PREPEND_NAMESPACE(TrFunctionAliasManager) trFunctionAliasManager;
127
128#endif
int main(int argc, char *argv[])
[2]
Definition buffer.cpp:77
bool m_sourceIsUtf16
Definition translator.h:52
static QString transcode(const QString &str)
Definition main.cpp:140
void processProjects(bool topLevel, UpdateOptions options, const Projects &projects, bool nestComplain, Translator *parentTor, bool *fail) const
Definition main.cpp:663
ProjectProcessor(const QString &sourceLanguage, const QString &targetLanguage)
Definition main.cpp:656
bool hasError() const
Definition qrcreader.h:17
QStringList availableFunctionsWithAliases() const
Definition main.cpp:113
QStringList listAliases() const
Definition main.cpp:125
int trFunctionByName(const QString &trFunctionName) const
Definition main.cpp:68
void modifyAlias(int trFunction, const QString &alias, Operation op)
Definition main.cpp:76
const NameToTrFunctionMap & nameToTrFunctionMap() const
Definition main.cpp:98
bool isAliasFor(const QString &identifier, TrFunction trFunction) const
Definition lupdate.h:108
int messageCount() const
Definition translator.h:146
const TranslatorMessage & constMessage(int i) const
Definition translator.h:149
void loadCPP(Translator &translator, const QStringList &filenames, ConversionData &cd)
Definition cpp.cpp:2278
bool loadJava(Translator &translator, const QString &filename, ConversionData &cd)
Definition java.cpp:562
bool loadJSModule(Translator &translator, const QString &filename, ConversionData &cd)
#define LUPDATE_FOR_EACH_TR_FUNCTION(UNARY_MACRO)
Definition lupdate.h:56
bool loadQml(Translator &translator, const QString &filename, ConversionData &cd)
bool loadPython(Translator &translator, const QString &fileName, ConversionData &cd)
Definition python.cpp:749
bool loadQScript(Translator &translator, const QString &filename, ConversionData &cd)
UpdateOption
Definition lupdate.h:23
@ NoLocations
Definition lupdate.h:32
@ Verbose
Definition lupdate.h:24
@ NoObsolete
Definition lupdate.h:25
@ PluralOnly
Definition lupdate.h:26
@ Werror
Definition lupdate.h:35
@ NoSort
Definition lupdate.h:27
@ HeuristicSimilarText
Definition lupdate.h:29
@ SourceIsUtf16
Definition lupdate.h:34
@ HeuristicSameText
Definition lupdate.h:28
@ AbsoluteLocations
Definition lupdate.h:30
@ RelativeLocations
Definition lupdate.h:31
@ NoUiLines
Definition lupdate.h:33
bool loadUI(Translator &translator, const QString &filename, ConversionData &cd)
Definition ui.cpp:157
std::vector< Project > Projects
Q_STATIC_ASSERT(sizeof(SharedImageHeader) % 4==0)
static void printUsage()
Definition main.cpp:60
static void printOut(const QString &out)
Definition main.cpp:18
static void printErr(const QString &out)
Definition main.cpp:23
static QStringList getResources(const QString &resourceFile)
Definition main.cpp:514
static void processSources(Translator &fetchedTor, const QStringList &sourceFiles, ConversionData &cd, UpdateOptions options, bool *fail)
Definition main.cpp:576
static QString m_defaultExtensions
Definition main.cpp:191
static void printWarning(UpdateOptions options, const QString &msg, const QString &warningMsg={}, const QString &errorMsg={})
Definition main.cpp:203
QStringList rootDirs
Definition main.cpp:33
static QStringList availableFunctions()
Definition main.cpp:104
static int trFunctionByDefaultName(const QString &trFunctionName)
Definition main.cpp:51
static void removeExcludedSources(Projects &projects)
Definition main.cpp:499
static const QString defaultTrFunctionNames[]
Definition main.cpp:38
static void expandQrcFiles(Project &project)
Definition main.cpp:551
bool useClangToParseCpp
Definition main.cpp:30
static void recursiveFileInfoList(const QDir &dir, const QSet< QString > &nameFilters, QDir::Filters filter, QFileInfoList *fileinfolist)
Definition main.cpp:222
TrFunctionAliasManager trFunctionAliasManager
Definition main.cpp:138
static bool readFileContent(const QString &filePath, QByteArray *content, QString *errorString)
Definition main.cpp:479
QString commandLineCompilationDatabaseDir
Definition main.cpp:31
static void updateTsFiles(const Translator &fetchedTor, const QStringList &tsFileNames, const QStringList &alienFiles, const QString &sourceLanguage, const QString &targetLanguage, UpdateOptions options, bool *fail)
Definition main.cpp:359
static bool processTs(Translator &fetchedTor, const QString &file, ConversionData &cd)
Definition main.cpp:557
static QSet< QString > projectRoots(const QString &projectFile, const QStringList &sourceFiles)
Definition main.cpp:636
static bool handleTrFunctionAliases(const QString &arg)
Definition main.cpp:329
static QStringList extractQrcFiles(Project &project)
Definition main.cpp:533