author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 14 May 2010 16:40:13 +0300 | |
changeset 22 | 79de32ba3296 |
parent 18 | 2f34d5167611 |
child 33 | 3e2da88830cd |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the test suite of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
// IMPORTANT!!!! If you want to add testdata to this file, |
|
43 |
// always add it to the end in order to not change the linenumbers of translations!!! |
|
44 |
int main(char **argv, int argc) |
|
45 |
{ |
|
46 |
Size size = QSize(1,1); |
|
47 |
} |
|
48 |
||
49 |
QString qt_detectRTLLanguage() |
|
50 |
{ |
|
51 |
return QApplication::tr("QT_LAYOUT_DIRECTION", |
|
52 |
"Translate this string to the string 'LTR' in left-to-right" |
|
53 |
" languages or to 'RTL' in right-to-left languages (such as Hebrew" |
|
54 |
" and Arabic) to get proper widget layout.") == QLatin1String("RTL"); |
|
55 |
} |
|
56 |
||
57 |
||
58 |
class Dialog2 : public QDialog |
|
59 |
{ |
|
60 |
Q_OBJECT |
|
61 |
void func(); |
|
62 |
void func3(); |
|
63 |
int getCount() const { return 2; } |
|
64 |
||
65 |
}; |
|
66 |
||
67 |
void Dialog2::func() |
|
68 |
{ |
|
69 |
int n = getCount(); |
|
70 |
tr("%n files", "plural form", n); |
|
71 |
tr("%n cars", 0, n); |
|
72 |
tr("&Find %n cars", 0, n); |
|
73 |
tr("Search in %n items?", 0, n); |
|
74 |
tr("%1. Search in %n items?", 0, n); |
|
75 |
tr("Age: %1"); |
|
76 |
tr("There are %n house(s)", "Plurals and function call", getCount()); |
|
77 |
||
78 |
||
79 |
||
80 |
||
81 |
QCoreApplication::translate("Plurals, QCoreApplication", "%n house(s)", "Plurals and identifier", QCoreApplication::UnicodeUTF8, n); |
|
82 |
QCoreApplication::translate("Plurals, QCoreApplication", "%n car(s)", "Plurals and literal number", QCoreApplication::UnicodeUTF8, 1); |
|
83 |
QCoreApplication::translate("Plurals, QCoreApplication", "%n horse(s)", "Plurals and function call", QCoreApplication::UnicodeUTF8, getCount()); |
|
84 |
||
85 |
||
86 |
||
87 |
||
88 |
||
89 |
||
90 |
||
91 |
||
92 |
QTranslator trans; |
|
93 |
trans.translate("QTranslator", "Simple"); |
|
94 |
trans.translate("QTranslator", "Simple", 0); |
|
95 |
trans.translate("QTranslator", "Simple with comment", "with comment"); |
|
96 |
trans.translate("QTranslator", "Plural without comment", 0, 1); |
|
97 |
trans.translate("QTranslator", "Plural with comment", "comment 1", n); |
|
98 |
trans.translate("QTranslator", "Plural with comment", "comment 2", getCount()); |
|
99 |
||
100 |
||
101 |
||
102 |
||
103 |
||
104 |
||
105 |
||
106 |
||
107 |
||
108 |
||
109 |
||
110 |
||
111 |
} |
|
112 |
||
113 |
||
114 |
||
115 |
||
116 |
/* This is actually a test of how many alternative ways a struct/class can be found in a source file. |
|
117 |
* Due to the simple parser in lupdate, it will actually not treat the remaining lines in the define |
|
118 |
* as a macro, which is a case the 'Tok_Class' parser block might not consider, and it might loop infinite |
|
119 |
* if it just tries to fetch the next token until it gets a '{' or a ';'. Another pitfall is that the |
|
120 |
* context of tr("func3") might not be parsed, it won't resume normal evaluation until the '{' after the function |
|
121 |
* signature. |
|
122 |
* |
|
123 |
*/ |
|
124 |
typedef struct S_ |
|
125 |
{ |
|
126 |
int a; |
|
127 |
} S, *SPtr; |
|
128 |
class ForwardDecl; |
|
129 |
||
130 |
||
131 |
#define FT_DEFINE_SERVICE( name ) \ |
|
132 |
typedef struct FT_Service_ ## name ## Rec_ \ |
|
133 |
FT_Service_ ## name ## Rec ; \ |
|
134 |
typedef struct FT_Service_ ## name ## Rec_ \ |
|
135 |
const * FT_Service_ ## name ; \ |
|
136 |
struct FT_Service_ ## name ## Rec_ |
|
137 |
||
138 |
||
139 |
/* removing this comment will break this test */ |
|
140 |
||
141 |
void Dialog2::func3() |
|
142 |
{ |
|
143 |
tr("func3"); |
|
144 |
} |
|
145 |
||
146 |
||
147 |
||
148 |
||
149 |
namespace Gui { class BaseClass {}; } |
|
150 |
||
151 |
||
152 |
class TestClass : QObject { |
|
153 |
Q_OBJECT |
|
154 |
||
155 |
||
156 |
inline QString inlineFunc1() { |
|
157 |
return tr("inline function", "TestClass"); |
|
158 |
} |
|
159 |
||
160 |
QString inlineFunc2() { |
|
161 |
return tr("inline function 2", "TestClass"); |
|
162 |
} |
|
163 |
||
164 |
static inline QString staticInlineFunc() { |
|
165 |
return tr("static inline function", "TestClass"); |
|
166 |
} |
|
167 |
||
168 |
class NoQObject : public Gui::BaseClass { |
|
169 |
public: |
|
170 |
inline QString hello() { return QString("hello"); } |
|
171 |
||
172 |
}; |
|
173 |
||
174 |
}; |
|
175 |
||
176 |
||
177 |
class Testing : QObject { |
|
178 |
Q_OBJECT |
|
179 |
||
180 |
inline QString f1() { |
|
181 |
//: this is an extra comment for the translator |
|
182 |
return tr("extra-commented string"); |
|
183 |
return tr("not extra-commented string"); |
|
184 |
/*: another extra-comment */ |
|
185 |
return tr("another extra-commented string"); |
|
186 |
/*: blah! */ |
|
187 |
return QApplication::translate("scope", "works in translate, too", "blabb", 0); |
|
188 |
} |
|
189 |
||
190 |
}; |
|
191 |
||
192 |
//: extra comment for NOOP |
|
193 |
//: which spans multiple lines |
|
194 |
QT_TRANSLATE_NOOP("scope", "string") // 4.4 says the line of this is at the next statement |
|
195 |
//: extra comment for NOOP3 |
|
196 |
QT_TRANSLATE_NOOP3_UTF8("scope", "string", "comment") // 4.4 doesn't see this |
|
197 |
||
198 |
QT_TRANSLATE_NOOP("scope", "string " // this is an interleaved comment |
|
199 |
"continuation on next line") |
|
200 |
||
201 |
||
202 |
class TestingTake17 : QObject { |
|
203 |
Q_OBJECT |
|
204 |
||
205 |
int function(void) |
|
206 |
{ |
|
207 |
//: random comment |
|
208 |
//= this_is_an_id |
|
209 |
//~ loc-layout_id fooish_bar |
|
210 |
//~ po-ignore_me totally foo-barred nonsense |
|
211 |
tr("something cool"); |
|
212 |
||
213 |
tr("less cool"); |
|
214 |
||
215 |
//= another_id |
|
216 |
tr("even more cool"); |
|
217 |
} |
|
218 |
}; |
|
219 |
||
220 |
||
221 |
||
222 |
||
223 |
//: again an extra comment, this time for id-based NOOP |
|
224 |
//% "This is supposed\tto be quoted \" newline\n" |
|
225 |
//% "backslashed \\ stuff." |
|
226 |
QT_TRID_NOOP("this_a_id") |
|
227 |
||
228 |
//~ some thing |
|
229 |
//% "This needs to be here. Really." |
|
230 |
QString test = qtTrId("this_another_id", n); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
231 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
232 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
233 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
234 |
class YetAnotherTest : QObject { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
235 |
Q_OBJECT |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
236 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
237 |
int function(void) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
238 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
239 |
// |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
240 |
//: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
241 |
//= |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
242 |
//~ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
243 |
//# |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
244 |
//============= |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
245 |
//~~~~~~~~~~~~~ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
246 |
//::::::::::::: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
247 |
tr("nothing"); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
248 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
249 |
}; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
250 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
251 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
252 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
253 |
//: This is a message without a source string |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
254 |
QString test = qtTrId("yet_another_id"); |
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
255 |
|
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
256 |
|
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
257 |
|
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
258 |
// QTBUG-9276: context in static initializers |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
259 |
class Bogus : QObject { |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
260 |
Q_OBJECT |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
261 |
|
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
262 |
static const char * const s_strings[]; |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
263 |
}; |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
264 |
|
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
265 |
const char * const Bogus::s_strings[] = { |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
266 |
QT_TR_NOOP("this should be in Bogus") |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
267 |
}; |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
268 |
|
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
269 |
const char * const Bogus::s_strings[SIZE] = { |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
270 |
QT_TR_NOOP("this should be in Bogus") |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
271 |
}; |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
272 |
|
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
273 |
void bogosity() |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
274 |
{ |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
275 |
// no spaces here. test collateral damage from ignoring equal sign |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
276 |
Class::member=QObject::tr("just QObject"); |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
277 |
} |