| 1 |
// Copyright (C) 2016 The Qt Company Ltd. |
| 2 |
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
// IMPORTANT!!!! If you want to add testdata to this file, |
| 30 |
// always add it to the end in order to not change the linenumbers of translations!!! |
| 31 |
int main(int argc, char **argv) |
| 32 |
{ |
| 33 |
//Size size = QSize(1,1); |
| 34 |
} |
| 35 |
#include <QtCore> |
| 36 |
QString qt_detectRTLLanguage() |
| 37 |
{ |
| 38 |
return QCoreApplication::tr("QT_LAYOUT_DIRECTION", |
| 39 |
"Translate this string to the string 'LTR' in left-to-right" |
| 40 |
" languages or to 'RTL' in right-to-left languages (such as Hebrew" |
| 41 |
" and Arabic) to get proper widget layout.");// == QLatin1String("RTL"); |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
class Dialog2 |
| 46 |
{ |
| 47 |
Q_OBJECT |
| 48 |
void func(); |
| 49 |
void func3(); |
| 50 |
int getCount() const { return 2; } |
| 51 |
|
| 52 |
}; |
| 53 |
|
| 54 |
void Dialog2::func() |
| 55 |
{ |
| 56 |
int n = getCount(); |
| 57 |
tr("%n files", "plural form", n); |
| 58 |
tr("%n cars", 0, n); |
| 59 |
tr("&Find %n cars", 0, n); |
| 60 |
tr("Search in %n items?", 0, n); |
| 61 |
tr("%1. Search in %n items?", 0, n); |
| 62 |
tr("Age: %1"); |
| 63 |
tr("There are %n house(s)", "Plurals and function call", getCount()); |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
QCoreApplication::translate("Plurals, QCoreApplication", "%n house(s)", "Plurals and identifier", n); |
| 69 |
QCoreApplication::translate("Plurals, QCoreApplication", "%n car(s)", "Plurals and literal number", 1); |
| 70 |
QCoreApplication::translate("Plurals, QCoreApplication", "%n horse(s)", "Plurals and function call", getCount()); |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
QTranslator trans; |
| 80 |
trans.translate("QTranslator", "Simple"); |
| 81 |
trans.translate("QTranslator", "Simple", 0); |
| 82 |
trans.translate("QTranslator", "Simple with comment", "with comment"); |
| 83 |
trans.translate("QTranslator", "Plural without comment", 0, 1); |
| 84 |
trans.translate("QTranslator", "Plural with comment", "comment 1", n); |
| 85 |
trans.translate("QTranslator", "Plural with comment", "comment 2", getCount()); |
| 86 |
trans.translate("QTranslator", "Plural with comment and static cast", "comment 3", |
| 87 |
static_cast<long>(getCount())); |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
} |
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
/* This is actually a test of how many alternative ways a struct/class can be found in a source file. |
| 104 |
* Due to the simple parser in lupdate, it will actually not treat the remaining lines in the define |
| 105 |
* as a macro, which is a case the 'Tok_Class' parser block might not consider, and it might loop infinite |
| 106 |
* if it just tries to fetch the next token until it gets a '{' or a ';'. Another pitfall is that the |
| 107 |
* context of tr("func3") might not be parsed, it won't resume normal evaluation until the '{' after the function |
| 108 |
* signature. |
| 109 |
* |
| 110 |
*/ |
| 111 |
typedef struct S_ |
| 112 |
{ |
| 113 |
int a; |
| 114 |
} S, *SPtr; |
| 115 |
class ForwardDecl; |
| 116 |
|
| 117 |
|
| 118 |
#define FT_DEFINE_SERVICE( name ) \ |
| 119 |
typedef struct FT_Service_ ## name ## Rec_ \ |
| 120 |
FT_Service_ ## name ## Rec ; \ |
| 121 |
typedef struct FT_Service_ ## name ## Rec_ \ |
| 122 |
const * FT_Service_ ## name ; \ |
| 123 |
struct FT_Service_ ## name ## Rec_ |
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
void Dialog2::func3() |
| 129 |
{ |
| 130 |
tr("func3"); |
| 131 |
} |
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
namespace Gui { class BaseClass {}; } |
| 137 |
|
| 138 |
|
| 139 |
class TestClass : QObject { |
| 140 |
Q_OBJECT |
| 141 |
|
| 142 |
|
| 143 |
inline QString inlineFunc1() { |
| 144 |
return tr("inline function", "TestClass"); |
| 145 |
} |
| 146 |
|
| 147 |
QString inlineFunc2() { |
| 148 |
return tr("inline function 2", "TestClass"); |
| 149 |
} |
| 150 |
|
| 151 |
static inline QString staticInlineFunc() { |
| 152 |
return tr("static inline function", "TestClass"); |
| 153 |
} |
| 154 |
|
| 155 |
class NoQObject : public Gui::BaseClass { |
| 156 |
public: |
| 157 |
inline QString hello() { return QString("hello"); } |
| 158 |
|
| 159 |
}; |
| 160 |
|
| 161 |
}; |
| 162 |
|
| 163 |
|
| 164 |
class Testing : QObject { |
| 165 |
Q_OBJECT |
| 166 |
|
| 167 |
inline QString f1() { |
| 168 |
//: this is an extra comment for the translator |
| 169 |
return tr("extra-commented string"); |
| 170 |
return tr("not extra-commented string"); |
| 171 |
/*: another extra-comment */ |
| 172 |
return tr("another extra-commented string"); |
| 173 |
/*: blah! */ |
| 174 |
return QCoreApplication::translate("scope", "works in translate, too", "blabb", 0); |
| 175 |
} |
| 176 |
|
| 177 |
}; |
| 178 |
|
| 179 |
//: extra comment for NOOP |
| 180 |
//: which spans multiple lines |
| 181 |
const char *c_1 = QT_TRANSLATE_NOOP("scope", "string") /*: complain & ignore */; // 4.4 says the line of this is at the next statement |
| 182 |
//: extra comment for NOOP3 |
| 183 |
const char *c_2[2] = QT_TRANSLATE_NOOP3_UTF8("scope", "string", "comment"); // 4.4 doesn't see this |
| 184 |
|
| 185 |
const char *c_3 = QT_TRANSLATE_NOOP("scope", "string " // this is an interleaved comment |
| 186 |
"continuation on next line"); |
| 187 |
|
| 188 |
|
| 189 |
class TestingTake17 : QObject { |
| 190 |
Q_OBJECT |
| 191 |
|
| 192 |
void function(void) |
| 193 |
{ |
| 194 |
//: random comment |
| 195 |
//= this_is_an_id |
| 196 |
//~ loc-layout_id fooish_bar |
| 197 |
//~ po-ignore_me totally foo-barred nonsense |
| 198 |
tr("something cool"); |
| 199 |
|
| 200 |
tr("less cool"); |
| 201 |
|
| 202 |
//= another_id |
| 203 |
tr("even more cool"); |
| 204 |
} |
| 205 |
}; |
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
//: again an extra comment, this time for id-based NOOP |
| 211 |
//% "This is supposed\tto be quoted \" newline\n" |
| 212 |
//% "backslashed \\ stuff." |
| 213 |
const char *c_4 = QT_TRID_NOOP("this_a_id"); |
| 214 |
|
| 215 |
//~ some thing |
| 216 |
//% "This needs to be here. Really." |
| 217 |
QString test = qtTrId("this_another_id", 2); |
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
class YetAnotherTest : QObject { |
| 222 |
Q_OBJECT |
| 223 |
|
| 224 |
void function(void) |
| 225 |
{ |
| 226 |
// |
| 227 |
//: |
| 228 |
//= |
| 229 |
//~ |
| 230 |
//# |
| 231 |
//============= |
| 232 |
//~~~~~~~~~~~~~ |
| 233 |
//::::::::::::: |
| 234 |
tr("nothing"); |
| 235 |
} |
| 236 |
}; |
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
//: This is a message without a source string |
| 241 |
QString test1 = qtTrId("yet_another_id"); |
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
// QTBUG-9276: context in static initializers |
| 246 |
class Bogus : QObject { |
| 247 |
Q_OBJECT |
| 248 |
static const char * const s_stringss[]; |
| 249 |
static const char * const s_strings[]; |
| 250 |
}; |
| 251 |
|
| 252 |
const char * const Bogus::s_strings[] = { |
| 253 |
QT_TR_NOOP("this should be in Bogus") |
| 254 |
}; |
| 255 |
|
| 256 |
const char * const Bogus::s_stringss[] = { |
| 257 |
QT_TR_NOOP("this should be in Bogus") |
| 258 |
}; |
| 259 |
|
| 260 |
void bogosity() |
| 261 |
{ |
| 262 |
// no spaces here. test collateral damage from ignoring equal sign |
| 263 |
QString toto=QObject::tr("just QObject"); |
| 264 |
} |
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
namespace Internal { |
| 269 |
|
| 270 |
class Message : public QObject |
| 271 |
{ |
| 272 |
Q_OBJECT |
| 273 |
public: |
| 274 |
Message(QObject *parent = 0); |
| 275 |
}; |
| 276 |
|
| 277 |
} // The temporary closing of the namespace triggers the problem |
| 278 |
|
| 279 |
namespace Internal { |
| 280 |
|
| 281 |
static inline QString message1() |
| 282 |
{ |
| 283 |
return Message::tr("message1"); // Had no namespace |
| 284 |
} |
| 285 |
|
| 286 |
static inline QString message2() |
| 287 |
{ |
| 288 |
return Message::tr("message2"); // Already had namespace |
| 289 |
} |
| 290 |
|
| 291 |
} |
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
// QTBUG-11426: operator overloads |
| 296 |
class LotsaFun : public QObject |
| 297 |
{ |
| 298 |
Q_OBJECT |
| 299 |
public: |
| 300 |
LotsaFun *operator<<(int i); |
| 301 |
}; |
| 302 |
|
| 303 |
LotsaFun *LotsaFun::operator<<(int i) |
| 304 |
{ |
| 305 |
tr("this is inside operator<<"); |
| 306 |
return this; |
| 307 |
} |
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
// QTBUG-12683: define in re-opened namespace |
| 312 |
namespace NameSchpace { |
| 313 |
|
| 314 |
class YetMoreFun : public QObject |
| 315 |
{ |
| 316 |
Q_OBJECT |
| 317 |
public: |
| 318 |
void funStuff(); |
| 319 |
}; |
| 320 |
|
| 321 |
} |
| 322 |
|
| 323 |
namespace NameSchpace { |
| 324 |
|
| 325 |
#define somevar 1 |
| 326 |
|
| 327 |
void YetMoreFun::funStuff() |
| 328 |
{ |
| 329 |
tr("funStuff!"); |
| 330 |
} |
| 331 |
|
| 332 |
} |
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
// QTBUG-29998: tr() macro inside square brackets |
| 337 |
void blubb() |
| 338 |
{ |
| 339 |
QMap<QString, QString> d; |
| 340 |
d[LotsaFun::tr("bracketed")] = "plain"; |
| 341 |
} |
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
// QTBUG-9276 part 2: QT_TR_NOOP in static member initializers |
| 346 |
class TestClass2 |
| 347 |
{ |
| 348 |
Q_DECLARE_TR_FUNCTIONS(TestClass); |
| 349 |
|
| 350 |
public: |
| 351 |
static const char TEST_STRING[]; |
| 352 |
}; |
| 353 |
|
| 354 |
const char TestClass2::TEST_STRING[] = QT_TR_NOOP("Test value"); |
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
// derivation from namespaced class |
| 359 |
class Class42 : public NameSchpace::YetMoreFun, Gui::BaseClass |
| 360 |
{ |
| 361 |
Q_OBJECT |
| 362 |
void foo(); |
| 363 |
Class42() : |
| 364 |
NameSchpace::YetMoreFun(), |
| 365 |
Gui::BaseClass() |
| 366 |
{ |
| 367 |
tr("does that make sense?"); |
| 368 |
} |
| 369 |
void hello(int something, QString str); |
| 370 |
}; |
| 371 |
|
| 372 |
|
| 373 |
void Class42::foo() |
| 374 |
{ |
| 375 |
tr("and does that?"); |
| 376 |
} |
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
// QTBUG-11866: magic comment parsing is too greedy |
| 381 |
void Class42::hello(int something /*= 17 */, QString str = Class42::tr("eyo")) |
| 382 |
{ |
| 383 |
} |
| 384 |
|
| 385 |
|
| 386 |
|
| 387 |
// QTBUG-27974: strings from included sources are not collected |
| 388 |
#include "included.cpp" |
| 389 |
|
| 390 |
// test TR_EXCLUDE |
| 391 |
#include "notincluded.cpp" |
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
// failure to update index on insertion messes up subsequent de-duplication |
| 396 |
void dupeFail() |
| 397 |
{ |
| 398 |
// First just the Id. |
| 399 |
qtTrId("dupe_id"); |
| 400 |
|
| 401 |
// Then with source |
| 402 |
//% "This is the source" |
| 403 |
qtTrId("dupe_id"); |
| 404 |
|
| 405 |
// Finally, same source, but without ID. |
| 406 |
QCoreApplication::translate("", "This is the source"); |
| 407 |
} |
| 408 |
|
| 409 |
|
| 410 |
|
| 411 |
// QTBUG-42735: lupdate confused by `final` specifier (C++11) |
| 412 |
namespace Abc { |
| 413 |
|
| 414 |
class NamespacedFinalClass; |
| 415 |
|
| 416 |
} |
| 417 |
|
| 418 |
class FinalClass final : public QObject |
| 419 |
{ |
| 420 |
Q_OBJECT |
| 421 |
|
| 422 |
class SubClass final |
| 423 |
{ |
| 424 |
void f() |
| 425 |
{ |
| 426 |
tr("nested class context with final"); |
| 427 |
} |
| 428 |
}; |
| 429 |
|
| 430 |
void f() |
| 431 |
{ |
| 432 |
tr("class context with final"); |
| 433 |
} |
| 434 |
}; |
| 435 |
|
| 436 |
class Abc::NamespacedFinalClass final : public QObject |
| 437 |
{ |
| 438 |
Q_OBJECT |
| 439 |
|
| 440 |
void f() |
| 441 |
{ |
| 442 |
tr("namespaced class with final"); |
| 443 |
} |
| 444 |
}; |
| 445 |
|
| 446 |
|
| 447 |
|
| 448 |
// QTBUG-48776: lupdate fails to recognize translator comment in ternary |
| 449 |
// operator construct |
| 450 |
void ternary() |
| 451 |
{ |
| 452 |
const auto aaa = |
| 453 |
true ? |
| 454 |
//: comment, aaa, true |
| 455 |
QObject::tr("ternary, true, aaa") : |
| 456 |
QObject::tr("ternary, failure, aaa"); |
| 457 |
|
| 458 |
const auto bbb = |
| 459 |
true ? |
| 460 |
//: comment, bbb, true |
| 461 |
QObject::tr("ternary, bbb, true") : |
| 462 |
//: comment, bbb, false |
| 463 |
QObject::tr("ternary, bbb, false"); |
| 464 |
} |
| 465 |
|
| 466 |
class TernaryClass : public QObject |
| 467 |
{ |
| 468 |
Q_OBJECT |
| 469 |
|
| 470 |
void f() |
| 471 |
{ |
| 472 |
const auto ccc = |
| 473 |
true ? |
| 474 |
//: comment, ccc, true |
| 475 |
tr("ternary, ccc, true") : |
| 476 |
tr("ternary, ccc, false"); |
| 477 |
|
| 478 |
const auto ddd = |
| 479 |
true ? |
| 480 |
//: comment, ddd, true |
| 481 |
tr("ternary, ddd, true") : |
| 482 |
//: comment, ddd, false |
| 483 |
tr("ternary, ddd, false"); |
| 484 |
} |
| 485 |
}; |
| 486 |
|
| 487 |
|
| 488 |
|
| 489 |
// QTBUG-47467: lupdate confused by nullptr in case of plural forms |
| 490 |
void nullptrInPlural() |
| 491 |
{ |
| 492 |
QObject::tr("%n nullptr(s)", nullptr, 3); |
| 493 |
QCoreApplication::translate("Plurals, nullptr", "%n car(s)", nullptr, 1); |
| 494 |
} |
| 495 |
|
| 496 |
class nullptrClass : public QObject |
| 497 |
{ |
| 498 |
Q_OBJECT |
| 499 |
|
| 500 |
void f() |
| 501 |
{ |
| 502 |
tr("%n car(s)", nullptr, 2); |
| 503 |
} |
| 504 |
}; |
| 505 |
|
| 506 |
|
| 507 |
|
| 508 |
// QTBUG-34265: lupdate does not detect NULL and Q_NULLPTR as 0 when being passed as context |
| 509 |
void nullMacroInPlural() |
| 510 |
{ |
| 511 |
QObject::tr("%n NULL(s)", NULL, 3); |
| 512 |
QObject::tr("%n Q_NULLPTR(s)", Q_NULLPTR, 3); |
| 513 |
} |
| 514 |
|
| 515 |
|
| 516 |
|
| 517 |
// QTBUG-34128: lupdate ignores tr() calls in constructor if a member is |
| 518 |
// initialized with C++11 initializer list |
| 519 |
class ListInitializationClass : public NameSchpace::YetMoreFun, Gui::BaseClass |
| 520 |
{ |
| 521 |
Q_OBJECT |
| 522 |
|
| 523 |
ListInitializationClass() : |
| 524 |
NameSchpace::YetMoreFun(), |
| 525 |
Gui::BaseClass{ }, |
| 526 |
a{ 0 }, |
| 527 |
b(1), |
| 528 |
c(tr("Hello World")) |
| 529 |
{ |
| 530 |
tr("ListInitializationClass in-class constructor"); |
| 531 |
} |
| 532 |
|
| 533 |
ListInitializationClass(int a); |
| 534 |
|
| 535 |
ListInitializationClass(int a, int b, int c); |
| 536 |
|
| 537 |
int a; |
| 538 |
int b; |
| 539 |
QString c; |
| 540 |
}; |
| 541 |
|
| 542 |
ListInitializationClass::ListInitializationClass(int a)// : |
| 543 |
// b{ { 2, 3 }}[a] |
| 544 |
{ |
| 545 |
tr("ListInitializationClass out-of-class single member initializer"); |
| 546 |
} |
| 547 |
|
| 548 |
ListInitializationClass::ListInitializationClass(int a, int b, int c) : |
| 549 |
NameSchpace::YetMoreFun{ }, |
| 550 |
Gui::BaseClass(), |
| 551 |
a{ 2 + (a/3) }, |
| 552 |
b(b), |
| 553 |
c{ tr("%n item(s)", Q_NULLPTR, c) } |
| 554 |
{ |
| 555 |
tr("ListInitializationClass out-of-class multi member initializer"); |
| 556 |
} |
| 557 |
|
| 558 |
|
| 559 |
|
| 560 |
// QTBUG-42166: lupdate is confused by C++11 lambdas in constructor initializer lists |
| 561 |
class LambdaMemberClass : public Gui::BaseClass |
| 562 |
{ |
| 563 |
Q_OBJECT |
| 564 |
|
| 565 |
LambdaMemberClass() : |
| 566 |
Gui::BaseClass(), |
| 567 |
a{ [](){ /*std::cout << */QObject::tr("Hello"); } }, |
| 568 |
b([](){ /*std::cout << "World\n";*/ }) |
| 569 |
{ |
| 570 |
tr("LambdaMemberClass in-class constructor"); |
| 571 |
} |
| 572 |
|
| 573 |
LambdaMemberClass(void *); |
| 574 |
|
| 575 |
std::function<void()> a; |
| 576 |
std::function<void()> b; |
| 577 |
}; |
| 578 |
|
| 579 |
LambdaMemberClass::LambdaMemberClass(void *) : |
| 580 |
Gui::BaseClass{ }, |
| 581 |
a([](){ /*std::cout <<*/ QObject::tr("Hallo "); }), |
| 582 |
b{ [](){ /*std::cout << "Welt\n";*/ } } |
| 583 |
{ |
| 584 |
tr("LambdaMemberClass out-of-class constructor"); |
| 585 |
} |
| 586 |
|
| 587 |
|
| 588 |
|
| 589 |
// Template parameters in base class initialization |
| 590 |
class TemplateClass : QVarLengthArray<char, sizeof(std::size_t)>, std::vector<int> |
| 591 |
{ |
| 592 |
Q_DECLARE_TR_FUNCTIONS(TemplateClass) |
| 593 |
QString member; |
| 594 |
|
| 595 |
public: |
| 596 |
TemplateClass() : |
| 597 |
QVarLengthArray<char, sizeof(std::size_t)>(), |
| 598 |
std::vector<int>(3), |
| 599 |
member(tr("TemplateClass() in-class member initialization")) |
| 600 |
{ |
| 601 |
tr("TemplateClass() in-class body"); |
| 602 |
} |
| 603 |
|
| 604 |
TemplateClass(void *); |
| 605 |
TemplateClass(int); |
| 606 |
}; |
| 607 |
|
| 608 |
// supported: combination of parens in base class template parameter with direct initialization (parens) |
| 609 |
TemplateClass::TemplateClass(void *) : |
| 610 |
QVarLengthArray<char, sizeof(std::size_t)>(), |
| 611 |
std::vector<int>{ 1, 2 }, |
| 612 |
member{ tr("TemplateClass(void *) out-of-class member initialization") } |
| 613 |
{ |
| 614 |
tr("TemplateClass(void *) out-of-class body"); |
| 615 |
} |
| 616 |
|
| 617 |
// not supported: combination of parens in base class template parameter with list initialization (braces) |
| 618 |
TemplateClass::TemplateClass(int) : |
| 619 |
QVarLengthArray<char, sizeof(std::size_t)>{ 3, 4, 5 }, |
| 620 |
member(tr("[unsupported] TemplateClass(int) out-of-class member initialization")) |
| 621 |
{ |
| 622 |
tr("[unsupported] TemplateClass(int) out-of-class body"); |
| 623 |
} |
| 624 |
|
| 625 |
|
| 626 |
|
| 627 |
// Related to QTBUG-53644, adapted from qglobal.h. |
| 628 |
// Namespace Private must be parsed correctly for TranslatedAfterPrivate to work. |
| 629 |
namespace Private { |
| 630 |
template <class T> struct Class1 { T t; }; |
| 631 |
template <class T> struct Class1<T &> : Class1<T> {}; |
| 632 |
template <class T> struct Class2 { enum { Value = sizeof(T) }; }; |
| 633 |
} // namespace Private |
| 634 |
class TranslatedAfterPrivate |
| 635 |
{ |
| 636 |
Q_OBJECT |
| 637 |
TranslatedAfterPrivate() |
| 638 |
{ |
| 639 |
tr("Must be in context TranslatedAfterPrivate"); |
| 640 |
} |
| 641 |
}; |
| 642 |
|
| 643 |
#include<QObject> |
| 644 |
class AClass { |
| 645 |
QString aa = QObject::tr("message after system include without space"); |
| 646 |
}; |
| 647 |
#include"qobject.h" |
| 648 |
class AAClass { |
| 649 |
QString aa = QObject::tr("message after local include without space"); |
| 650 |
}; |
| 651 |
|
| 652 |
|
| 653 |
// QTBUG-35164: handling of \uNNNN escapes |
| 654 |
QString unicodeEscape() |
| 655 |
{ |
| 656 |
return QCoreApplication::tr("Context", "soft\u00ADhyphen"); |
| 657 |
} |
| 658 |
|
| 659 |
|
| 660 |
|
| 661 |
// QTBUG-63364: C++17 nested namespaces |
| 662 |
namespace Outer::Inner { |
| 663 |
|
| 664 |
class Class |
| 665 |
{ |
| 666 |
Q_OBJECT |
| 667 |
void function() |
| 668 |
{ |
| 669 |
tr("MoreFunStuff!"); |
| 670 |
} |
| 671 |
}; |
| 672 |
|
| 673 |
} |
| 674 |
|
| 675 |
|
| 676 |
|
| 677 |
// test of translation for _N_ family |
| 678 |
static const char * const test_string_n1[] = { |
| 679 |
QT_TRANSLATE_N_NOOP("scope", "string %n") |
| 680 |
}; |
| 681 |
|
| 682 |
static const char * const test_string_n2[] = |
| 683 |
QT_TRANSLATE_N_NOOP3("scope", "string %n", "comment") |
| 684 |
; |
| 685 |
class testing { Q_OBJECT |
| 686 |
void test(); }; |
| 687 |
void testing::test() { static const char * const test_string_n3[] = { |
| 688 |
QT_TR_N_NOOP("%n test") |
| 689 |
}; |
| 690 |
} |
| 691 |
|
| 692 |
|
| 693 |
|
| 694 |
// QTBUG-91521: context in static initializers with parentheses |
| 695 |
class Hogus : QObject { |
| 696 |
Q_OBJECT |
| 697 |
static const QString myString; |
| 698 |
}; |
| 699 |
|
| 700 |
const QString Hogus::myString(QT_TR_NOOP("this should be in Hogus")); |
| 701 |
|
| 702 |
|
| 703 |
|
| 704 |
// QTBUG-99415: multiple specifiers after method parameter list |
| 705 |
class QTBUG99415 : QObject { |
| 706 |
Q_OBJECT |
| 707 |
const QString text1() const noexcept { return tr("text1"); } |
| 708 |
const QString text2() const noexcept; |
| 709 |
}; |
| 710 |
|
| 711 |
const QString QTBUG99415::text2() const noexcept { return tr("text2"); } |
| 712 |
|
| 713 |
// QTBUG-110630: Support quoting in extras field to allow whitespace preservation |
| 714 |
class QTBUG110630 : QObject { |
| 715 |
Q_OBJECT |
| 716 |
const QString txt() { |
| 717 |
//~ quoted " string with spaces " |
| 718 |
tr("translation with extras-quoted field"); |
| 719 |
} |
| 720 |
}; |
| 721 |
|
| 722 |
// enum class - C++11 |
| 723 |
enum class Bar : unsigned short; |
| 724 |
// QTBUG-36589: Don't treat enum classes as a normal class |
| 725 |
class QTBUG36589 : QObject { |
| 726 |
Q_OBJECT |
| 727 |
const QString txt() { |
| 728 |
tr("string after an enum class"); |
| 729 |
} |
| 730 |
}; |
| 731 |
|
| 732 |
class TestMetaStrings : QObject |
| 733 |
{ |
| 734 |
Q_OBJECT |
| 735 |
void func() |
| 736 |
{ |
| 737 |
//= id1 |
| 738 |
//@ label1 |
| 739 |
tr("msg with id1"); |
| 740 |
|
| 741 |
//@ label2 |
| 742 |
tr("invalid usage of label because of missing id"); |
| 743 |
|
| 744 |
//@ label3 |
| 745 |
//% "propagating label" |
| 746 |
qtTrId("id2"); |
| 747 |
|
| 748 |
qtTrId("id2"); |
| 749 |
|
| 750 |
//% "invalid usage of label, contradicting labels for id" |
| 751 |
//@ label4 |
| 752 |
qtTrId("id4"); |
| 753 |
//@ label5 |
| 754 |
qtTrId("id4"); |
| 755 |
|
| 756 |
//@ label6 |
| 757 |
} |
| 758 |
}; |