Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qttranslation.qdoc
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5 \macro QT_TR_NOOP(sourceText)
6 \relates <QtTranslation>
7
8 Marks the UTF-8 encoded string literal \a sourceText for delayed
9 translation in the current context (class).
10
11 The macro tells lupdate to collect the string, and expands to
12 \a sourceText itself.
13
14 Example:
15
16 \snippet code/src_corelib_global_qglobal.cpp 34
17
18 The macro QT_TR_NOOP_UTF8() is identical and obsolete; this applies
19 to all other _UTF8 macros as well.
20
21 \sa QT_TRANSLATE_NOOP(), {Internationalization with Qt}
22*/
23
24/*!
25 \macro QT_TRANSLATE_NOOP(context, sourceText)
26 \relates <QtTranslation>
27
28 Marks the UTF-8 encoded string literal \a sourceText for delayed
29 translation in the given \a context. The \a context is typically
30 a class name and also needs to be specified as a string literal.
31
32 The macro tells lupdate to collect the string, and expands to
33 \a sourceText itself.
34
35 Example:
36
37 \snippet code/src_corelib_global_qglobal.cpp 35
38
39 \sa QT_TR_NOOP(), QT_TRANSLATE_NOOP3(), {Internationalization with Qt}
40*/
41
42/*!
43 \macro QT_TRANSLATE_NOOP3(context, sourceText, disambiguation)
44 \relates <QtTranslation>
45 \since 4.4
46
47 Marks the UTF-8 encoded string literal \a sourceText for delayed
48 translation in the given \a context with the given \a disambiguation.
49 The \a context is typically a class and also needs to be specified
50 as a string literal. The string literal \a disambiguation should be
51 a short semantic tag to tell apart otherwise identical strings.
52
53 The macro tells lupdate to collect the string, and expands to an
54 anonymous struct of the two string literals passed as \a sourceText
55 and \a disambiguation.
56
57 Example:
58
59 \snippet code/src_corelib_global_qglobal.cpp 36
60
61 \sa QT_TR_NOOP(), QT_TRANSLATE_NOOP(), {Internationalization with Qt}
62*/
63
64/*!
65 \macro QT_TR_N_NOOP(sourceText)
66 \relates <QtTranslation>
67 \since 5.12
68
69 Marks the UTF-8 encoded string literal \a sourceText for numerator
70 dependent delayed translation in the current context (class).
71
72 The macro tells lupdate to collect the string, and expands to
73 \a sourceText itself.
74
75 The macro expands to \a sourceText.
76
77 Example:
78
79 \snippet code/src_corelib_global_qglobal.cpp qttrnnoop
80
81 \sa QT_TR_NOOP, {Internationalization with Qt}
82*/
83
84/*!
85 \macro QT_TRANSLATE_N_NOOP(context, sourceText)
86 \relates <QtTranslation>
87 \since 5.12
88
89 Marks the UTF-8 encoded string literal \a sourceText for numerator
90 dependent delayed translation in the given \a context.
91 The \a context is typically a class name and also needs to be
92 specified as a string literal.
93
94 The macro tells lupdate to collect the string, and expands to
95 \a sourceText itself.
96
97 Example:
98
99 \snippet code/src_corelib_global_qglobal.cpp qttranslatennoop
100
101 \sa QT_TRANSLATE_NOOP(), QT_TRANSLATE_N_NOOP3(),
102 {Internationalization with Qt}
103*/
104
105/*!
106 \macro QT_TRANSLATE_N_NOOP3(context, sourceText, comment)
107 \relates <QtTranslation>
108 \since 5.12
109
110 Marks the UTF-8 encoded string literal \a sourceText for numerator
111 dependent delayed translation in the given \a context with the given
112 \a comment.
113 The \a context is typically a class and also needs to be specified
114 as a string literal. The string literal \a comment should be
115 a short semantic tag to tell apart otherwise identical strings.
116
117 The macro tells lupdate to collect the string, and expands to an
118 anonymous struct of the two string literals passed as \a sourceText
119 and \a comment.
120
121 Example:
122
123 \snippet code/src_corelib_global_qglobal.cpp qttranslatennoop3
124
125 \sa QT_TR_NOOP(), QT_TRANSLATE_NOOP(), QT_TRANSLATE_NOOP3(),
126 {Internationalization with Qt}
127*/
128
129/*!
130 \fn QString qtTrId(const char *id, int n = -1)
131 \relates <QtTranslation>
132 \reentrant
133 \since 4.6
134
135 \brief The qtTrId function finds and returns a translated string.
136
137 Returns a translated string identified by \a id.
138 If no matching string is found, the id itself is returned. This
139 should not happen under normal conditions.
140
141 If \a n >= 0, all occurrences of \c %n in the resulting string
142 are replaced with a decimal representation of \a n. In addition,
143 depending on \a n's value, the translation text may vary.
144
145 Meta data and comments can be passed as documented for QObject::tr().
146 In addition, it is possible to supply a source string template like that:
147
148 \tt{//% <C string>}
149
150 or
151
152 \tt{\\begincomment% <C string> \\endcomment}
153
154 Example:
155
156 \snippet code/src_corelib_global_qglobal.cpp qttrid
157
158 Creating QM files suitable for use with this function requires passing
159 the \c -idbased option to the \c lrelease tool.
160
161 \warning This method is reentrant only if all translators are
162 installed \e before calling this method. Installing or removing
163 translators while performing translations is not supported. Doing
164 so will probably result in crashes or other undesirable behavior.
165
166 \sa QObject::tr(), QCoreApplication::translate(), {Internationalization with Qt}
167*/
168
169/*!
170 \macro QT_TRID_NOOP(id)
171 \relates <QtTranslation>
172 \since 4.6
173
174 \brief The QT_TRID_NOOP macro marks an id for dynamic translation.
175
176 The only purpose of this macro is to provide an anchor for attaching
177 meta data like to qtTrId().
178
179 The macro expands to \a id.
180
181 Example:
182
183 \snippet code/src_corelib_global_qglobal.cpp qttrid_noop
184
185 \sa qtTrId(), {Internationalization with Qt}
186*/
187
188/*!
189 \macro QT_TRID_N_NOOP(id)
190 \relates <QtTranslation>
191 \since 6.3
192
193 \brief The QT_TRID_N_NOOP macro marks an id for numerator
194 dependent dynamic translation.
195
196 The only purpose of this macro is to provide an anchor for attaching
197 meta data like to qtTrId().
198
199 The macro expands to \a id.
200
201 Example:
202
203 \snippet code/src_corelib_global_qglobal.cpp qttrid_n_noop
204
205 \sa qtTrId(), {Internationalization with Qt}
206*/