Extract header qtranslation.h from qglobal.h

As a drive-by, fixed the sorting order of header includes.

Task-number: QTBUG-99313
Change-Id: I731e397f8488460657b31839c49f07ff3c476c66
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Sona Kurazyan 2022-07-28 10:47:20 +02:00
parent ea8645d846
commit 19454b05c2
5 changed files with 250 additions and 229 deletions

View File

@ -68,6 +68,7 @@ qt_internal_add_module(Core
global/qsystemdetection.h
global/qtnamespacemacros.h
global/qtrace_p.h
global/qtranslation.h
global/qtypeinfo.h
global/qvolatile_p.h
global/q20algorithm.h

View File

@ -3840,210 +3840,6 @@ bool qunsetenv(const char *varName)
enumeration's underlying type.
*/
/*!
\macro QT_TR_NOOP(sourceText)
\relates <QtGlobal>
Marks the UTF-8 encoded string literal \a sourceText for delayed
translation in the current context (class).
The macro tells lupdate to collect the string, and expands to
\a sourceText itself.
Example:
\snippet code/src_corelib_global_qglobal.cpp 34
The macro QT_TR_NOOP_UTF8() is identical and obsolete; this applies
to all other _UTF8 macros as well.
\sa QT_TRANSLATE_NOOP(), {Internationalization with Qt}
*/
/*!
\macro QT_TRANSLATE_NOOP(context, sourceText)
\relates <QtGlobal>
Marks the UTF-8 encoded string literal \a sourceText for delayed
translation in the given \a context. The \a context is typically
a class name and also needs to be specified as a string literal.
The macro tells lupdate to collect the string, and expands to
\a sourceText itself.
Example:
\snippet code/src_corelib_global_qglobal.cpp 35
\sa QT_TR_NOOP(), QT_TRANSLATE_NOOP3(), {Internationalization with Qt}
*/
/*!
\macro QT_TRANSLATE_NOOP3(context, sourceText, disambiguation)
\relates <QtGlobal>
\since 4.4
Marks the UTF-8 encoded string literal \a sourceText for delayed
translation in the given \a context with the given \a disambiguation.
The \a context is typically a class and also needs to be specified
as a string literal. The string literal \a disambiguation should be
a short semantic tag to tell apart otherwise identical strings.
The macro tells lupdate to collect the string, and expands to an
anonymous struct of the two string literals passed as \a sourceText
and \a disambiguation.
Example:
\snippet code/src_corelib_global_qglobal.cpp 36
\sa QT_TR_NOOP(), QT_TRANSLATE_NOOP(), {Internationalization with Qt}
*/
/*!
\macro QT_TR_N_NOOP(sourceText)
\relates <QtGlobal>
\since 5.12
Marks the UTF-8 encoded string literal \a sourceText for numerator
dependent delayed translation in the current context (class).
The macro tells lupdate to collect the string, and expands to
\a sourceText itself.
The macro expands to \a sourceText.
Example:
\snippet code/src_corelib_global_qglobal.cpp qttrnnoop
\sa QT_TR_NOOP, {Internationalization with Qt}
*/
/*!
\macro QT_TRANSLATE_N_NOOP(context, sourceText)
\relates <QtGlobal>
\since 5.12
Marks the UTF-8 encoded string literal \a sourceText for numerator
dependent delayed translation in the given \a context.
The \a context is typically a class name and also needs to be
specified as a string literal.
The macro tells lupdate to collect the string, and expands to
\a sourceText itself.
Example:
\snippet code/src_corelib_global_qglobal.cpp qttranslatennoop
\sa QT_TRANSLATE_NOOP(), QT_TRANSLATE_N_NOOP3(),
{Internationalization with Qt}
*/
/*!
\macro QT_TRANSLATE_N_NOOP3(context, sourceText, comment)
\relates <QtGlobal>
\since 5.12
Marks the UTF-8 encoded string literal \a sourceText for numerator
dependent delayed translation in the given \a context with the given
\a comment.
The \a context is typically a class and also needs to be specified
as a string literal. The string literal \a comment should be
a short semantic tag to tell apart otherwise identical strings.
The macro tells lupdate to collect the string, and expands to an
anonymous struct of the two string literals passed as \a sourceText
and \a comment.
Example:
\snippet code/src_corelib_global_qglobal.cpp qttranslatennoop3
\sa QT_TR_NOOP(), QT_TRANSLATE_NOOP(), QT_TRANSLATE_NOOP3(),
{Internationalization with Qt}
*/
/*!
\fn QString qtTrId(const char *id, int n = -1)
\relates <QtGlobal>
\reentrant
\since 4.6
\brief The qtTrId function finds and returns a translated string.
Returns a translated string identified by \a id.
If no matching string is found, the id itself is returned. This
should not happen under normal conditions.
If \a n >= 0, all occurrences of \c %n in the resulting string
are replaced with a decimal representation of \a n. In addition,
depending on \a n's value, the translation text may vary.
Meta data and comments can be passed as documented for QObject::tr().
In addition, it is possible to supply a source string template like that:
\tt{//% <C string>}
or
\tt{\\begincomment% <C string> \\endcomment}
Example:
\snippet code/src_corelib_global_qglobal.cpp qttrid
Creating QM files suitable for use with this function requires passing
the \c -idbased option to the \c lrelease tool.
\warning This method is reentrant only if all translators are
installed \e before calling this method. Installing or removing
translators while performing translations is not supported. Doing
so will probably result in crashes or other undesirable behavior.
\sa QObject::tr(), QCoreApplication::translate(), {Internationalization with Qt}
*/
/*!
\macro QT_TRID_NOOP(id)
\relates <QtGlobal>
\since 4.6
\brief The QT_TRID_NOOP macro marks an id for dynamic translation.
The only purpose of this macro is to provide an anchor for attaching
meta data like to qtTrId().
The macro expands to \a id.
Example:
\snippet code/src_corelib_global_qglobal.cpp qttrid_noop
\sa qtTrId(), {Internationalization with Qt}
*/
/*!
\macro QT_TRID_N_NOOP(id)
\relates <QtGlobal>
\since 6.3
\brief The QT_TRID_N_NOOP macro marks an id for numerator
dependent dynamic translation.
The only purpose of this macro is to provide an anchor for attaching
meta data like to qtTrId().
The macro expands to \a id.
Example:
\snippet code/src_corelib_global_qglobal.cpp qttrid_n_noop
\sa qtTrId(), {Internationalization with Qt}
*/
/*!
\macro Q_LIKELY(expr)
\relates <QtGlobal>

View File

@ -1213,30 +1213,6 @@ template <typename Ptr> inline auto qGetPtrHelper(Ptr &ptr) noexcept -> decltype
#define Q_D(Class) Class##Private * const d = d_func()
#define Q_Q(Class) Class * const q = q_func()
#define QT_TR_NOOP(x) x
#define QT_TR_NOOP_UTF8(x) x
#define QT_TRANSLATE_NOOP(scope, x) x
#define QT_TRANSLATE_NOOP_UTF8(scope, x) x
#define QT_TRANSLATE_NOOP3(scope, x, comment) {x, comment}
#define QT_TRANSLATE_NOOP3_UTF8(scope, x, comment) {x, comment}
#ifndef QT_NO_TRANSLATION
#define QT_TR_N_NOOP(x) x
#define QT_TRANSLATE_N_NOOP(scope, x) x
#define QT_TRANSLATE_N_NOOP3(scope, x, comment) {x, comment}
// Defined in qcoreapplication.cpp
// The better name qTrId() is reserved for an upcoming function which would
// return a much more powerful QStringFormatter instead of a QString.
Q_CORE_EXPORT QString qtTrId(const char *id, int n = -1);
#define QT_TRID_NOOP(id) id
#define QT_TRID_N_NOOP(id) id
#endif // QT_NO_TRANSLATION
#ifdef Q_QDOC
// Just for documentation generation
template<typename T>
@ -1343,10 +1319,11 @@ QT_END_NAMESPACE
#include <QtCore/qflags.h>
#include <QtCore/qatomic.h>
#include <QtCore/qforeach.h>
#include <QtCore/qglobalstatic.h>
#include <QtCore/qnumeric.h>
#include <QtCore/qtranslation.h>
#include <QtCore/qversiontagging.h>
#include <QtCore/qforeach.h>
#endif /* __cplusplus */
#endif /* !__ASSEMBLER__ */

View File

@ -0,0 +1,41 @@
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QTRANSLATION_H
#define QTRANSLATION_H
#include <QtCore/qglobal.h>
#if 0
#pragma qt_class(QTranslation)
#pragma qt_sync_stop_processing
#endif
QT_BEGIN_NAMESPACE
#define QT_TR_NOOP(x) x
#define QT_TR_NOOP_UTF8(x) x
#define QT_TRANSLATE_NOOP(scope, x) x
#define QT_TRANSLATE_NOOP_UTF8(scope, x) x
#define QT_TRANSLATE_NOOP3(scope, x, comment) {x, comment}
#define QT_TRANSLATE_NOOP3_UTF8(scope, x, comment) {x, comment}
#ifndef QT_NO_TRANSLATION
#define QT_TR_N_NOOP(x) x
#define QT_TRANSLATE_N_NOOP(scope, x) x
#define QT_TRANSLATE_N_NOOP3(scope, x, comment) {x, comment}
// Defined in qcoreapplication.cpp
// The better name qTrId() is reserved for an upcoming function which would
// return a much more powerful QStringFormatter instead of a QString.
Q_CORE_EXPORT QString qtTrId(const char *id, int n = -1);
#define QT_TRID_NOOP(id) id
#define QT_TRID_N_NOOP(id) id
QT_END_NAMESPACE
#endif // QT_NO_TRANSLATION
#endif /* QTRANSLATION_H */

View File

@ -0,0 +1,206 @@
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\macro QT_TR_NOOP(sourceText)
\relates <QTranslation>
Marks the UTF-8 encoded string literal \a sourceText for delayed
translation in the current context (class).
The macro tells lupdate to collect the string, and expands to
\a sourceText itself.
Example:
\snippet code/src_corelib_global_qglobal.cpp 34
The macro QT_TR_NOOP_UTF8() is identical and obsolete; this applies
to all other _UTF8 macros as well.
\sa QT_TRANSLATE_NOOP(), {Internationalization with Qt}
*/
/*!
\macro QT_TRANSLATE_NOOP(context, sourceText)
\relates <QTranslation>
Marks the UTF-8 encoded string literal \a sourceText for delayed
translation in the given \a context. The \a context is typically
a class name and also needs to be specified as a string literal.
The macro tells lupdate to collect the string, and expands to
\a sourceText itself.
Example:
\snippet code/src_corelib_global_qglobal.cpp 35
\sa QT_TR_NOOP(), QT_TRANSLATE_NOOP3(), {Internationalization with Qt}
*/
/*!
\macro QT_TRANSLATE_NOOP3(context, sourceText, disambiguation)
\relates <QTranslation>
\since 4.4
Marks the UTF-8 encoded string literal \a sourceText for delayed
translation in the given \a context with the given \a disambiguation.
The \a context is typically a class and also needs to be specified
as a string literal. The string literal \a disambiguation should be
a short semantic tag to tell apart otherwise identical strings.
The macro tells lupdate to collect the string, and expands to an
anonymous struct of the two string literals passed as \a sourceText
and \a disambiguation.
Example:
\snippet code/src_corelib_global_qglobal.cpp 36
\sa QT_TR_NOOP(), QT_TRANSLATE_NOOP(), {Internationalization with Qt}
*/
/*!
\macro QT_TR_N_NOOP(sourceText)
\relates <QTranslation>
\since 5.12
Marks the UTF-8 encoded string literal \a sourceText for numerator
dependent delayed translation in the current context (class).
The macro tells lupdate to collect the string, and expands to
\a sourceText itself.
The macro expands to \a sourceText.
Example:
\snippet code/src_corelib_global_qglobal.cpp qttrnnoop
\sa QT_TR_NOOP, {Internationalization with Qt}
*/
/*!
\macro QT_TRANSLATE_N_NOOP(context, sourceText)
\relates <QTranslation>
\since 5.12
Marks the UTF-8 encoded string literal \a sourceText for numerator
dependent delayed translation in the given \a context.
The \a context is typically a class name and also needs to be
specified as a string literal.
The macro tells lupdate to collect the string, and expands to
\a sourceText itself.
Example:
\snippet code/src_corelib_global_qglobal.cpp qttranslatennoop
\sa QT_TRANSLATE_NOOP(), QT_TRANSLATE_N_NOOP3(),
{Internationalization with Qt}
*/
/*!
\macro QT_TRANSLATE_N_NOOP3(context, sourceText, comment)
\relates <QTranslation>
\since 5.12
Marks the UTF-8 encoded string literal \a sourceText for numerator
dependent delayed translation in the given \a context with the given
\a comment.
The \a context is typically a class and also needs to be specified
as a string literal. The string literal \a comment should be
a short semantic tag to tell apart otherwise identical strings.
The macro tells lupdate to collect the string, and expands to an
anonymous struct of the two string literals passed as \a sourceText
and \a comment.
Example:
\snippet code/src_corelib_global_qglobal.cpp qttranslatennoop3
\sa QT_TR_NOOP(), QT_TRANSLATE_NOOP(), QT_TRANSLATE_NOOP3(),
{Internationalization with Qt}
*/
/*!
\fn QString qtTrId(const char *id, int n = -1)
\relates <QTranslation>
\reentrant
\since 4.6
\brief The qtTrId function finds and returns a translated string.
Returns a translated string identified by \a id.
If no matching string is found, the id itself is returned. This
should not happen under normal conditions.
If \a n >= 0, all occurrences of \c %n in the resulting string
are replaced with a decimal representation of \a n. In addition,
depending on \a n's value, the translation text may vary.
Meta data and comments can be passed as documented for QObject::tr().
In addition, it is possible to supply a source string template like that:
\tt{//% <C string>}
or
\tt{\\begincomment% <C string> \\endcomment}
Example:
\snippet code/src_corelib_global_qglobal.cpp qttrid
Creating QM files suitable for use with this function requires passing
the \c -idbased option to the \c lrelease tool.
\warning This method is reentrant only if all translators are
installed \e before calling this method. Installing or removing
translators while performing translations is not supported. Doing
so will probably result in crashes or other undesirable behavior.
\sa QObject::tr(), QCoreApplication::translate(), {Internationalization with Qt}
*/
/*!
\macro QT_TRID_NOOP(id)
\relates <QTranslation>
\since 4.6
\brief The QT_TRID_NOOP macro marks an id for dynamic translation.
The only purpose of this macro is to provide an anchor for attaching
meta data like to qtTrId().
The macro expands to \a id.
Example:
\snippet code/src_corelib_global_qglobal.cpp qttrid_noop
\sa qtTrId(), {Internationalization with Qt}
*/
/*!
\macro QT_TRID_N_NOOP(id)
\relates <QTranslation>
\since 6.3
\brief The QT_TRID_N_NOOP macro marks an id for numerator
dependent dynamic translation.
The only purpose of this macro is to provide an anchor for attaching
meta data like to qtTrId().
The macro expands to \a id.
Example:
\snippet code/src_corelib_global_qglobal.cpp qttrid_n_noop
\sa qtTrId(), {Internationalization with Qt}
*/