22 #include "cutelee_paths.h"
23 #include "nulllocalizer_p.h"
24 #include "qtlocalizer.h"
27 #include "coverageobject.h"
28 #include <QtCore/QScopedPointer>
29 #include <QtCore/QTranslator>
30 #include <QtTest/QTest>
34 #if QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
35 #define FR_THOUSAND_SEPARATOR "\u00A0"
37 #define FR_THOUSAND_SEPARATOR "\u202F"
40 #define INIT_LOCALIZER(localizer) \
41 localizer->setAppTranslatorPrefix(QStringLiteral("test_")); \
42 localizer->setAppTranslatorPath(QStringLiteral(":/"));
51 new QtLocalizer(QLocale(QLocale::German, QLocale::Germany))),
52 frLocalizer(
new QtLocalizer(QLocale(QLocale::French, QLocale::France))),
54 new QtLocalizer(QLocale(QLocale::English, QLocale::UnitedKingdom))),
56 new QtLocalizer(QLocale(QLocale::English, QLocale::UnitedStates))),
59 auto cLocale = QLocale::c();
60 cLocale.setNumberOptions(QLocale::OmitGroupSeparator);
62 m_engine->setPluginPaths({QStringLiteral(CUTELEE_PLUGIN_PATH)});
63 INIT_LOCALIZER(cLocalizer)
64 INIT_LOCALIZER(deLocalizer)
65 INIT_LOCALIZER(frLocalizer)
66 INIT_LOCALIZER(en_GBLocalizer)
67 INIT_LOCALIZER(en_USLocalizer)
69 auto deTranslator =
new QTranslator(
this);
70 const auto result = deTranslator->load(QStringLiteral(
":/test_de_DE"));
73 deLocalizer->installTranslator(deTranslator, QStringLiteral(
"de_DE"));
77 auto frTranslator =
new QTranslator(
this);
78 const auto result = frTranslator->load(QStringLiteral(
":/test_fr_FR.qm"));
81 frLocalizer->installTranslator(frTranslator, QStringLiteral(
"fr_FR"));
83 m_engine->addDefaultLibrary(QStringLiteral(
"cutelee_i18ntags"));
96 void testLocalizedTemplate();
97 void testSafeContent();
100 void testStrings_data();
101 void testIntegers_data();
102 void testFloats_data();
103 void testDates_data();
104 void testTimes_data();
105 void testDateTimes_data();
106 void testLocalizedTemplate_data();
107 void testSafeContent_data();
108 void testFailure_data();
111 std::shared_ptr<QtLocalizer> cLocalizer;
112 const std::shared_ptr<AbstractLocalizer> nullLocalizer;
113 const std::shared_ptr<QtLocalizer> deLocalizer;
114 const std::shared_ptr<QtLocalizer> frLocalizer;
115 const std::shared_ptr<QtLocalizer> en_GBLocalizer;
116 const std::shared_ptr<QtLocalizer> en_USLocalizer;
121 void TestInternationalization::initTestCase() { Q_INIT_RESOURCE(testresource); }
123 void TestInternationalization::testContext()
129 c.
setLocalizer(std::shared_ptr<Cutelee::AbstractLocalizer>());
133 void TestInternationalization::testStrings()
139 QFETCH(
QString, disambiguation);
141 QFETCH(QVariantList, args);
143 if (!disambiguation.isEmpty()) {
144 if (!plural.isEmpty()) {
145 QCOMPARE(nullLocalizer->localizePluralContextString(input, plural,
146 disambiguation, args),
148 QCOMPARE(deLocalizer->localizePluralContextString(input, plural,
149 disambiguation, args),
151 QCOMPARE(frLocalizer->localizePluralContextString(input, plural,
152 disambiguation, args),
156 QCOMPARE(nullLocalizer->localizeContextString(input, disambiguation, args),
158 QCOMPARE(deLocalizer->localizeContextString(input, disambiguation, args),
160 QCOMPARE(frLocalizer->localizeContextString(input, disambiguation, args),
164 if (!plural.isEmpty()) {
165 QCOMPARE(nullLocalizer->localizePluralString(input, plural, args),
167 QCOMPARE(deLocalizer->localizePluralString(input, plural, args), de_output);
168 QCOMPARE(frLocalizer->localizePluralString(input, plural, args), fr_output);
171 QCOMPARE(nullLocalizer->localizeString(input, args), null_output);
172 QCOMPARE(deLocalizer->localizeString(input, args), de_output);
173 QCOMPARE(frLocalizer->localizeString(input, args), fr_output);
176 void TestInternationalization::testStrings_data()
178 QTest::addColumn<QString>(
"input");
179 QTest::addColumn<QString>(
"null_output");
180 QTest::addColumn<QString>(
"de_output");
181 QTest::addColumn<QString>(
"fr_output");
182 QTest::addColumn<QString>(
"disambiguation");
183 QTest::addColumn<QString>(
"plural");
184 QTest::addColumn<QVariantList>(
"args");
189 QTest::newRow(
"string-01")
195 QTest::newRow(
"string-02") <<
"%n People"
199 << QStringLiteral(
"%n People") << QVariantList{1};
201 QTest::newRow(
"string-03") <<
"%n People"
205 << QStringLiteral(
"%n People") << QVariantList{2};
207 QTest::newRow(
"string-04")
210 <<
"Name eines Buches"
211 <<
"Nom d'un livre" << QStringLiteral(
"Name of a Book") <<
QString()
214 QTest::newRow(
"string-05")
217 <<
"Namen einer Person"
218 <<
"Nom d'une personne" << QStringLiteral(
"Name of a Person") <<
QString()
221 QTest::newRow(
"string-06")
224 <<
"1 Person angemeldet" << QString::fromUtf8(
"1 Personne connecté")
225 << QStringLiteral(
"%n people are logged in")
226 << QStringLiteral(
"%n People") << QVariantList{1};
228 QTest::newRow(
"string-07")
231 <<
"2 Personen angemeldet" << QString::fromUtf8(
"2 Personnes connecté")
232 << QStringLiteral(
"%n people are logged in")
233 << QStringLiteral(
"%n People") << QVariantList{2};
235 QTest::newRow(
"string-08")
236 <<
"%n file(s) copied to %1"
237 <<
"1 files copied to destinationFolder"
238 <<
"1 Datei in destinationFolder kopiert"
239 << QString::fromUtf8(
"1 fichier copié dans destinationFolder")
240 <<
QString() << QStringLiteral(
"%n files copied to %1")
241 << QVariantList{1, QStringLiteral(
"destinationFolder")};
243 QTest::newRow(
"string-09")
244 <<
"%n file(s) copied to %1"
245 <<
"2 files copied to destinationFolder"
246 <<
"2 Datein in destinationFolder kopiert"
247 << QString::fromUtf8(
"2 fichiers copiés dans destinationFolder")
248 <<
QString() << QStringLiteral(
"%n files copied to %1")
249 << QVariantList{2, QStringLiteral(
"destinationFolder")};
251 QTest::newRow(
"string-10")
253 <<
"1 copied to destinationFolder"
254 <<
"1 Datei wird nach destinationFolder kopiert"
255 << QString::fromUtf8(
"1 fichier est copié sur destinationFolder")
256 << QStringLiteral(
"Files are being copied")
257 << QStringLiteral(
"%n copied to %1")
258 << QVariantList{1, QStringLiteral(
"destinationFolder")};
260 QTest::newRow(
"string-11")
262 <<
"1 copied to destinationFolder"
263 <<
"1 Datei war nach destinationFolder kopiert"
264 << QString::fromUtf8(
"1 fichier a été copié à destinationFolder")
265 << QStringLiteral(
"Files have already been copied")
266 << QStringLiteral(
"%n copied to %1")
267 << QVariantList{1, QStringLiteral(
"destinationFolder")};
269 QTest::newRow(
"string-12")
271 <<
"2 copied to destinationFolder"
272 <<
"2 Datein wird nach destinationFolder kopiert"
273 << QString::fromUtf8(
"2 fichiers sont copiés à destinationFolder")
274 << QStringLiteral(
"Files are being copied")
275 << QStringLiteral(
"%n copied to %1")
276 << QVariantList{2, QStringLiteral(
"destinationFolder")};
278 QTest::newRow(
"string-13")
280 <<
"2 copied to destinationFolder"
281 <<
"2 Datein war nach destinationFolder kopiert"
282 << QString::fromUtf8(
"2 fichiers ont été copiés sur destinationFolder")
283 << QStringLiteral(
"Files have already been copied")
284 << QStringLiteral(
"%n copied to %1")
285 << QVariantList{2, QStringLiteral(
"destinationFolder")};
287 QTest::newRow(
"string-14")
289 <<
"from sourceFolder to destinationFolder"
290 <<
"nach destinationFolder von sourceFolder"
291 << QString::fromUtf8(
"à partir de sourceFolder destinationFolder")
292 << QStringLiteral(
"Files are being copied from %1 to %2") <<
QString()
293 << QVariantList{QStringLiteral(
"sourceFolder"),
294 QStringLiteral(
"destinationFolder")};
296 QTest::newRow(
"string-15")
297 <<
"%1 messages at %2, fraction of total: %3. Rating : %4"
298 <<
"1000 messages at 2005-05-07, fraction of total: 0.6. Rating : 4.8"
299 <<
"1000 Nachrichten am 2005-05-07, ratio: 0.6. Bemessungen : 4.8"
300 << QStringLiteral(
"1000 messages au 2005-05-07, la fraction du total: "
303 << QVariantList{1000, QDate(2005, 5, 7), 0.6, 4.8};
306 QTest::newRow(
"string-16")
309 <<
"Schneemann: ☃" << QStringLiteral(
"bonhomme de neige: ☃") <<
QString()
310 <<
QString() << QVariantList();
314 typedef QHash<QString, QVariant> Dict;
316 void TestInternationalization::testLocalizedTemplate()
320 QFETCH(
QString, en_USFragment);
321 QFETCH(
QString, en_GBFragment);
326 auto t = m_engine->newTemplate(input,
QString());
329 QCOMPARE(t->render(&c), cFragment);
331 QCOMPARE(t->render(&c), en_USFragment);
333 QCOMPARE(t->render(&c), en_GBFragment);
335 QCOMPARE(t->render(&c), deFragment);
337 QCOMPARE(t->render(&c), frFragment);
340 void TestInternationalization::testLocalizedTemplate_data()
342 QTest::addColumn<QString>(
"input");
343 QTest::addColumn<QString>(
"cFragment");
344 QTest::addColumn<QString>(
"en_USFragment");
345 QTest::addColumn<QString>(
"en_GBFragment");
346 QTest::addColumn<QString>(
"deFragment");
347 QTest::addColumn<QString>(
"frFragment");
348 QTest::addColumn<Dict>(
"dict");
351 dict.insert(QStringLiteral(
"date"), QDate(2005, 5, 7));
352 QTest::newRow(
"fragment-01")
353 << QStringLiteral(
"{% i18n '%1 messages at %2, fraction of total: %3. "
354 "Rating : %4' _(1000) _(date) _(0.6) _(4.8) %}")
355 << QStringLiteral(
"1000 messages at 7 May 2005, fraction of total: 0.60. "
358 "1,000 messages at 5/7/05, fraction of total: 0.60. Rating : 4.80")
359 << QStringLiteral(
"1,000 messages at 07/05/2005, fraction of total: "
360 "0.60. Rating : 4.80")
362 "1.000 Nachrichten am 07.05.05, ratio: 0,60. Bemessungen : 4,80")
363 << QString::fromUtf8(
"1" FR_THOUSAND_SEPARATOR
364 "000 messages au 07/05/2005, la fraction du "
365 "total: 0,60. Note: 4,80")
368 dict.insert(QStringLiteral(
"integer"), 1000);
369 dict.insert(QStringLiteral(
"smallFloat"), 0.6);
370 dict.insert(QStringLiteral(
"largeFloat"), 4.8);
372 QTest::newRow(
"fragment-02")
374 "{% i18n '%1 messages at %2, fraction of total: %3. Rating : %4' "
375 "_(integer) _(date) _(smallFloat) _(largeFloat) %}")
376 << QStringLiteral(
"1000 messages at 7 May 2005, fraction of total: 0.60. "
379 "1,000 messages at 5/7/05, fraction of total: 0.60. Rating : 4.80")
380 << QStringLiteral(
"1,000 messages at 07/05/2005, fraction of total: "
381 "0.60. Rating : 4.80")
383 "1.000 Nachrichten am 07.05.05, ratio: 0,60. Bemessungen : 4,80")
384 << QString::fromUtf8(
"1" FR_THOUSAND_SEPARATOR
385 "000 messages au 07/05/2005, la fraction du "
386 "total: 0,60. Note: 4,80")
389 dict.insert(QStringLiteral(
"time"), QTime(4, 5, 6));
390 dict.insert(QStringLiteral(
"dateTime"),
391 QDateTime(QDate(2005, 5, 7), QTime(4, 5, 6)));
393 QTest::newRow(
"fragment-03")
395 "{{ _(integer) }} -- {{ _(date) }} -- {{ _(smallFloat) }} -- {{ "
396 "_(largeFloat) }} -- {{ _(time) }} -- {{ _(dateTime) }}")
397 << QStringLiteral(
"1000 -- 7 May 2005 -- 0.60 -- 4.80 -- 04:05:06 -- 7 "
400 "1,000 -- 5/7/05 -- 0.60 -- 4.80 -- 4:05 AM -- 5/7/05 4:05 AM")
402 "1,000 -- 07/05/2005 -- 0.60 -- 4.80 -- 04:05 -- 07/05/2005 04:05")
404 "1.000 -- 07.05.05 -- 0,60 -- 4,80 -- 04:05 -- 07.05.05 04:05")
405 << QString::fromUtf8(
"1" FR_THOUSAND_SEPARATOR
406 "000 -- 07/05/2005 -- 0,60 -- 4,80 -- 04:05 -- "
410 QTest::newRow(
"fragment-04")
411 << QString::fromLatin1(
412 "{{ _('Today') }} -- {{ _(integer) }} -- {{ _(date) }} -- {{ "
413 "_(smallFloat) }} -- {{ _(largeFloat) }} -- {{ _(time) }} -- {{ "
415 "{% with_locale 'de_DE' %}"
416 "{{ _('Today') }} -- {{ _(integer) }} -- {{ _(date) }} -- {{ "
417 "_(smallFloat) }} -- {{ _(largeFloat) }} -- {{ _(time) }} -- {{ "
419 "{% endwith_locale %}"
420 "{% with_locale 'fr_FR' %}"
421 "{{ _('Today') }} -- {{ _(integer) }} -- {{ _(date) }} -- {{ "
422 "_(smallFloat) }} -- {{ _(largeFloat) }} -- {{ _(time) }} -- {{ "
424 "{% endwith_locale %}")
425 << QString::fromUtf8(
427 " -- 1000 -- 7 May 2005 -- 0.60 -- 4.80 -- 04:05:06 -- 7 May "
431 " -- 1.000 -- 07.05.05 -- 0,60 -- 4,80 -- 04:05 -- 07.05.05 "
434 " -- 1" FR_THOUSAND_SEPARATOR
435 "000 -- 07/05/2005 -- 0,60 -- 4,80 -- 04:05 -- "
438 << QString::fromUtf8(
440 " -- 1,000 -- 5/7/05 -- 0.60 -- 4.80 -- 4:05 AM -- 5/7/05 4:05 "
443 " -- 1.000 -- 07.05.05 -- 0,60 -- 4,80 -- 04:05 -- 07.05.05 "
446 " -- 1" FR_THOUSAND_SEPARATOR
447 "000 -- 07/05/2005 -- 0,60 -- 4,80 -- 04:05 -- "
450 << QString::fromUtf8(
452 " -- 1,000 -- 07/05/2005 -- 0.60 -- 4.80 -- 04:05 -- 07/05/2005 "
455 " -- 1.000 -- 07.05.05 -- 0,60 -- 4,80 -- 04:05 -- 07.05.05 "
458 " -- 1" FR_THOUSAND_SEPARATOR
459 "000 -- 07/05/2005 -- 0,60 -- 4,80 -- 04:05 -- "
462 << QString::fromUtf8(
464 " -- 1.000 -- 07.05.05 -- 0,60 -- 4,80 -- 04:05 -- 07.05.05 "
467 " -- 1.000 -- 07.05.05 -- 0,60 -- 4,80 -- 04:05 -- 07.05.05 "
470 " -- 1" FR_THOUSAND_SEPARATOR
471 "000 -- 07/05/2005 -- 0,60 -- 4,80 -- 04:05 -- "
474 << QString::fromUtf8(
476 " -- 1" FR_THOUSAND_SEPARATOR
477 "000 -- 07/05/2005 -- 0,60 -- 4,80 -- 04:05 -- "
481 " -- 1.000 -- 07.05.05 -- 0,60 -- 4,80 -- 04:05 -- 07.05.05 "
484 " -- 1" FR_THOUSAND_SEPARATOR
485 "000 -- 07/05/2005 -- 0,60 -- 4,80 -- 04:05 -- "
490 QTest::newRow(
"fragment-05")
491 << QString::fromLatin1(
492 "{{ _('Today') }} -- {{ _(integer) }} -- {{ _(date) }} -- {{ "
493 "_(smallFloat) }} -- {{ _(largeFloat) }} -- {{ _(time) }} -- {{ "
495 "{% with_locale 'de_DE' %}"
496 "{{ _('Today') }} -- {{ _(integer) }} -- {{ _(date) }} -- {{ "
497 "_(smallFloat) }} -- {{ _(largeFloat) }} -- {{ _(time) }} -- {{ "
499 "{% with_locale 'fr_FR' %}"
500 "{{ _('Today') }} -- {{ _(integer) }} -- {{ _(date) }} -- {{ "
501 "_(smallFloat) }} -- {{ _(largeFloat) }} -- {{ _(time) }} -- {{ "
503 "{% endwith_locale %}"
504 "{{ _('Today') }} -- {{ _(integer) }} -- {{ _(date) }} -- {{ "
505 "_(smallFloat) }} -- {{ _(largeFloat) }} -- {{ _(time) }} -- {{ "
507 "{% endwith_locale %}")
508 << QString::fromUtf8(
510 " -- 1000 -- 7 May 2005 -- 0.60 -- 4.80 -- 04:05:06 -- 7 May "
514 " -- 1.000 -- 07.05.05 -- 0,60 -- 4,80 -- 04:05 -- 07.05.05 "
517 " -- 1" FR_THOUSAND_SEPARATOR
518 "000 -- 07/05/2005 -- 0,60 -- 4,80 -- 04:05 -- "
522 " -- 1.000 -- 07.05.05 -- 0,60 -- 4,80 -- 04:05 -- 07.05.05 "
524 << QString::fromUtf8(
526 " -- 1,000 -- 5/7/05 -- 0.60 -- 4.80 -- 4:05 AM -- 5/7/05 4:05 "
529 " -- 1.000 -- 07.05.05 -- 0,60 -- 4,80 -- 04:05 -- 07.05.05 "
532 " -- 1" FR_THOUSAND_SEPARATOR
533 "000 -- 07/05/2005 -- 0,60 -- 4,80 -- 04:05 -- "
537 " -- 1.000 -- 07.05.05 -- 0,60 -- 4,80 -- 04:05 -- 07.05.05 "
539 << QString::fromUtf8(
541 " -- 1,000 -- 07/05/2005 -- 0.60 -- 4.80 -- 04:05 -- 07/05/2005 "
544 " -- 1.000 -- 07.05.05 -- 0,60 -- 4,80 -- 04:05 -- 07.05.05 "
547 " -- 1" FR_THOUSAND_SEPARATOR
548 "000 -- 07/05/2005 -- 0,60 -- 4,80 -- 04:05 -- "
552 " -- 1.000 -- 07.05.05 -- 0,60 -- 4,80 -- 04:05 -- 07.05.05 "
554 << QString::fromUtf8(
556 " -- 1.000 -- 07.05.05 -- 0,60 -- 4,80 -- 04:05 -- 07.05.05 "
559 " -- 1.000 -- 07.05.05 -- 0,60 -- 4,80 -- 04:05 -- 07.05.05 "
562 " -- 1" FR_THOUSAND_SEPARATOR
563 "000 -- 07/05/2005 -- 0,60 -- 4,80 -- 04:05 -- "
567 " -- 1.000 -- 07.05.05 -- 0,60 -- 4,80 -- 04:05 -- 07.05.05 "
569 << QString::fromUtf8(
571 " -- 1" FR_THOUSAND_SEPARATOR
572 "000 -- 07/05/2005 -- 0,60 -- 4,80 -- 04:05 -- "
576 " -- 1.000 -- 07.05.05 -- 0,60 -- 4,80 -- 04:05 -- 07.05.05 "
579 " -- 1" FR_THOUSAND_SEPARATOR
580 "000 -- 07/05/2005 -- 0,60 -- 4,80 -- 04:05 -- "
584 " -- 1.000 -- 07.05.05 -- 0,60 -- 4,80 -- 04:05 -- 07.05.05 "
588 dict.insert(QStringLiteral(
"list"), QVariantList{1000});
589 QTest::newRow(
"fragment-06")
590 << QStringLiteral(
"{{ _(list.0) }}") << QStringLiteral(
"1000")
591 << QStringLiteral(
"1,000") << QStringLiteral(
"1,000")
592 << QStringLiteral(
"1.000")
593 << QString::fromUtf8(
"1" FR_THOUSAND_SEPARATOR
"000") << dict;
596 dict.insert(QStringLiteral(
"longlong"), (qlonglong)1000);
597 dict.insert(QStringLiteral(
"float"), (
float)0.6);
598 dict.insert(QStringLiteral(
"double"), (
float)4.8);
599 dict.insert(QStringLiteral(
"hash"), QVariantHash());
601 QTest::newRow(
"fragment-07")
603 "{{ _(longlong) }} {{ _(float) }} {{ _(double) }}{{ _(hash) }}")
604 << QStringLiteral(
"1000 0.60 4.80") << QStringLiteral(
"1,000 0.60 4.80")
605 << QStringLiteral(
"1,000 0.60 4.80") << QStringLiteral(
"1.000 0,60 4,80")
606 << QString::fromUtf8(
"1" FR_THOUSAND_SEPARATOR
"000 0,60 4,80") << dict;
608 QTest::newRow(
"fragment-08")
609 << QStringLiteral(
"{{ 'this'|cut:_(\"i\") }}") << QStringLiteral(
"ths")
610 << QStringLiteral(
"ths") << QStringLiteral(
"ths") << QStringLiteral(
"ths")
611 << QStringLiteral(
"ths") << dict;
619 dict.insert(QStringLiteral(
"fs_int_mib"), 1048576);
621 QTest::newRow(
"fragment-09")
622 << QStringLiteral(
"{% l10n_filesize fs_int_mib %}")
623 << QStringLiteral(
"1.05 MB") << QStringLiteral(
"1.05 MB")
624 << QStringLiteral(
"1.05 MB") << QStringLiteral(
"1,05 MB")
625 #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
626 << QStringLiteral(
"1,05 Mo")
628 << QStringLiteral(
"1,05 MB")
632 QTest::newRow(
"fragment-10")
633 << QStringLiteral(
"{% l10n_filesize_var fs_int_mib size_var %}{{ size_var }}")
634 << QStringLiteral(
"1.05 MB") << QStringLiteral(
"1.05 MB")
635 << QStringLiteral(
"1.05 MB") << QStringLiteral(
"1,05 MB")
636 #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
637 << QStringLiteral(
"1,05 Mo")
639 << QStringLiteral(
"1,05 MB")
643 QTest::newRow(
"fragment-11")
644 << QStringLiteral(
"{% l10n_filesize fs_int_mib 2 %}")
645 << QStringLiteral(
"1.00 MiB") << QStringLiteral(
"1.00 MiB")
646 << QStringLiteral(
"1.00 MiB") << QStringLiteral(
"1,00 MiB")
647 #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
648 << QStringLiteral(
"1,00 Mio")
650 << QStringLiteral(
"1,00 MiB")
654 QTest::newRow(
"fragment-12")
655 << QStringLiteral(
"{% l10n_filesize_var fs_int_mib 2 size_var %}{{ size_var }}")
656 << QStringLiteral(
"1.00 MiB") << QStringLiteral(
"1.00 MiB")
657 << QStringLiteral(
"1.00 MiB") << QStringLiteral(
"1,00 MiB")
658 #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
659 << QStringLiteral(
"1,00 Mio")
661 << QStringLiteral(
"1,00 MiB")
665 QTest::newRow(
"fragment-13")
666 << QStringLiteral(
"{% l10n_filesize fs_int_mib 10 3 %}")
667 << QStringLiteral(
"1.049 MB") << QStringLiteral(
"1.049 MB")
668 << QStringLiteral(
"1.049 MB") << QStringLiteral(
"1,049 MB")
669 #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
670 << QStringLiteral(
"1,049 Mo")
672 << QStringLiteral(
"1,049 MB")
676 QTest::newRow(
"fragment-14")
677 << QStringLiteral(
"{% l10n_filesize_var fs_int_mib 10 3 size_var %}{{ size_var }}")
678 << QStringLiteral(
"1.049 MB") << QStringLiteral(
"1.049 MB")
679 << QStringLiteral(
"1.049 MB") << QStringLiteral(
"1,049 MB")
680 #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
681 << QStringLiteral(
"1,049 Mo")
683 << QStringLiteral(
"1,049 MB")
687 QTest::newRow(
"fragment-15")
688 << QStringLiteral(
"{% l10n_filesize fs_int_mib 10 2 1024 %}")
689 << QStringLiteral(
"1.07 GB") << QStringLiteral(
"1.07 GB")
690 << QStringLiteral(
"1.07 GB") << QStringLiteral(
"1,07 GB")
691 #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
692 << QStringLiteral(
"1,07 Go")
694 << QStringLiteral(
"1,07 GB")
698 QTest::newRow(
"fragment-16")
699 << QStringLiteral(
"{% l10n_filesize_var fs_int_mib 10 2 1024 size_var %}{{ size_var }}")
700 << QStringLiteral(
"1.07 GB") << QStringLiteral(
"1.07 GB")
701 << QStringLiteral(
"1.07 GB") << QStringLiteral(
"1,07 GB")
702 #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
703 << QStringLiteral(
"1,07 Go")
705 << QStringLiteral(
"1,07 GB")
710 dict.insert(QStringLiteral(
"fs_float_mib"), 1024.5);
712 QTest::newRow(
"fragment-17")
713 << QStringLiteral(
"{% l10n_filesize fs_float_mib 10 2 1024 %}")
714 << QStringLiteral(
"1.05 MB") << QStringLiteral(
"1.05 MB")
715 << QStringLiteral(
"1.05 MB") << QStringLiteral(
"1,05 MB")
716 #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
717 << QStringLiteral(
"1,05 Mo")
719 << QStringLiteral(
"1,05 MB")
723 QTest::newRow(
"fragment-18")
724 << QStringLiteral(
"{% l10n_filesize_var fs_float_mib 10 2 1024 size_var %}{{ size_var }}")
725 << QStringLiteral(
"1.05 MB") << QStringLiteral(
"1.05 MB")
726 << QStringLiteral(
"1.05 MB") << QStringLiteral(
"1,05 MB")
727 #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
728 << QStringLiteral(
"1,05 Mo")
730 << QStringLiteral(
"1,05 MB")
735 dict.insert(QStringLiteral(
"fs_string_mib"), QStringLiteral(
"1024.5"));
737 QTest::newRow(
"fragment-19")
738 << QStringLiteral(
"{% l10n_filesize fs_string_mib 10 2 1024 %}")
739 << QStringLiteral(
"1.05 MB") << QStringLiteral(
"1.05 MB")
740 << QStringLiteral(
"1.05 MB") << QStringLiteral(
"1,05 MB")
741 #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
742 << QStringLiteral(
"1,05 Mo")
744 << QStringLiteral(
"1,05 MB")
748 QTest::newRow(
"fragment-20")
749 << QStringLiteral(
"{% l10n_filesize_var fs_string_mib 10 2 1024 size_var %}{{ size_var }}")
750 << QStringLiteral(
"1.05 MB") << QStringLiteral(
"1.05 MB")
751 << QStringLiteral(
"1.05 MB") << QStringLiteral(
"1,05 MB")
752 #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
753 << QStringLiteral(
"1,05 Mo")
755 << QStringLiteral(
"1,05 MB")
760 void TestInternationalization::testSafeContent()
767 auto t = m_engine->newTemplate(input,
QString());
770 QCOMPARE(t->render(&c), cFragment);
772 QCOMPARE(t->render(&c), frFragment);
775 void TestInternationalization::testSafeContent_data()
777 QTest::addColumn<QString>(
"input");
778 QTest::addColumn<QString>(
"cFragment");
779 QTest::addColumn<QString>(
"frFragment");
780 QTest::addColumn<Dict>(
"dict");
783 dict.insert(QStringLiteral(
"date"), QDate(2005, 5, 7));
785 QTest::newRow(
"safe-01") << QStringLiteral(
"{% i18n 'Today is %1' _(date) %}")
786 << QStringLiteral(
"Today is 7 May 2005")
787 << QStringLiteral(
"Aujourd'hui est 07/05/2005")
790 QTest::newRow(
"safe-02") << QStringLiteral(
791 "{% autoescape off %}{% i18n 'Today is %1' _(date) %}{% endautoescape %}")
792 << QStringLiteral(
"Today is 7 May 2005")
793 << QStringLiteral(
"Aujourd'hui est 07/05/2005")
796 QTest::newRow(
"safe-03") << QStringLiteral(
797 "{% i18n_var 'Today is %1' _(date) as today_greeting %}-{{ "
798 "today_greeting }}-") << QStringLiteral(
"-Today is 7 May 2005-")
799 << QStringLiteral(
"-Aujourd'hui est 07/05/2005-")
802 QTest::newRow(
"safe-04") << QStringLiteral(
803 "{% autoescape off %}{% i18n_var 'Today is %1' _(date) as today_greeting "
804 "%}-{{ today_greeting }}-{% endautoescape %}")
805 << QStringLiteral(
"-Today is 7 May 2005-")
806 << QStringLiteral(
"-Aujourd'hui est 07/05/2005-")
809 QTest::newRow(
"safe-05") << QStringLiteral(
810 "{% with 'Today' as rawText %}-{{ _(rawText) }}-{% endwith %}")
811 << QStringLiteral(
"-Today-")
812 << QStringLiteral(
"-Aujourd'hui-") << dict;
814 QTest::newRow(
"safe-06") << QStringLiteral(
815 "{% autoescape off %}{% with 'Today' as rawText %}-{{ _(rawText) }}-{% "
816 "endwith %}{% endautoescape %}")
817 << QStringLiteral(
"-Today-")
818 << QStringLiteral(
"-Aujourd'hui-") << dict;
820 dict.insert(QStringLiteral(
"today_text"), QStringLiteral(
"Today"));
822 QTest::newRow(
"safe-07") << QStringLiteral(
"-{{ _(today_text) }}-")
823 << QStringLiteral(
"-Today-")
824 << QStringLiteral(
"-Aujourd'hui-") << dict;
826 QTest::newRow(
"safe-08") << QStringLiteral(
827 "{% autoescape off %}-{{ _(today_text) }}-{% endautoescape %}")
828 << QStringLiteral(
"-Today-")
829 << QStringLiteral(
"-Aujourd'hui-") << dict;
831 dict.insert(QStringLiteral(
"today_and_tomorrow_text"),
832 markSafe(QStringLiteral(
"Today & tomorrow")));
834 QTest::newRow(
"safe-09")
835 << QStringLiteral(
"-{{ _(today_and_tomorrow_text) }}-")
836 << QStringLiteral(
"-Today &amp; tomorrow-")
837 << QStringLiteral(
"-Aujourd'hui &amp; demain-") << dict;
839 QTest::newRow(
"safe-10") << QStringLiteral(
840 "{% autoescape off %}-{{ _(today_and_tomorrow_text) }}-{% endautoescape "
841 "%}") << QStringLiteral(
"-Today & tomorrow-")
842 << QStringLiteral(
"-Aujourd'hui & demain-")
845 QTest::newRow(
"safe-11") << QStringLiteral(
846 "{% i18nc 'The current day is' 'Today is' %}")
847 << QStringLiteral(
"Today is")
848 << QStringLiteral(
"Aujourd'hui est") << dict;
850 QTest::newRow(
"safe-12") << QStringLiteral(
851 "{% autoescape off %}{% i18nc 'The current day is' 'Today is' %}{% "
852 "endautoescape %}") << QStringLiteral(
"Today is")
853 << QStringLiteral(
"Aujourd'hui est") << dict;
855 QTest::newRow(
"safe-13") << QStringLiteral(
856 "{% i18nc_var 'The current day is' 'Today is' as today_greeting %}-{{ "
857 "today_greeting }}-") << QStringLiteral(
"-Today is-")
858 << QStringLiteral(
"-Aujourd'hui est-") << dict;
860 QTest::newRow(
"safe-14") << QStringLiteral(
861 "{% autoescape off %}{% i18nc_var 'The current day is' 'Today is' as "
862 "today_greeting %}-{{ today_greeting }}-{% endautoescape %}")
863 << QStringLiteral(
"-Today is-")
864 << QStringLiteral(
"-Aujourd'hui est-") << dict;
866 QTest::newRow(
"safe-15")
867 << QStringLiteral(
"{% i18np '%n people today' 1 %}")
868 << QStringLiteral(
"1 people today")
869 << QStringLiteral(
"1 personne aujourd'hui") << dict;
871 QTest::newRow(
"safe-16") << QStringLiteral(
"{% i18np '%n people today' 2 %}")
872 << QStringLiteral(
"2 people today")
873 << QStringLiteral(
"2 personnes aujourd'hui")
876 QTest::newRow(
"safe-17") << QStringLiteral(
877 "{% autoescape off %}{% i18np '%n people today' 1 %}{% endautoescape %}")
881 << QStringLiteral(
"1 personne aujourd'hui") << dict;
883 QTest::newRow(
"safe-18") << QStringLiteral(
884 "{% autoescape off %}{% i18np '%n people today' 2 %}{% endautoescape %}")
885 << QStringLiteral(
"2 people today")
886 << QStringLiteral(
"2 personnes aujourd'hui") << dict;
888 QTest::newRow(
"safe-19") << QStringLiteral(
889 "{% i18np_var '%n people today' 1 as num_people %}-{{ num_people }}-")
893 << QStringLiteral(
"-1 personne aujourd'hui-")
896 QTest::newRow(
"safe-20") << QStringLiteral(
897 "{% i18np_var '%n people today' 2 as num_people %}-{{ num_people }}-")
898 << QStringLiteral(
"-2 people today-")
899 << QStringLiteral(
"-2 personnes aujourd'hui-")
902 QTest::newRow(
"safe-21")
903 << QStringLiteral(
"{% autoescape off %}{% i18np_var '%n people today' 1 "
904 "as num_people %}-{{ num_people }}-{% endautoescape %}")
905 << QStringLiteral(
"-1 people today-")
906 << QStringLiteral(
"-1 personne aujourd'hui-") << dict;
908 QTest::newRow(
"safe-22") << QStringLiteral(
909 "{% autoescape off %}{% i18np_var '%n people today' 2 as num_people "
910 "%}-{{ num_people }}-{% endautoescape %}")
911 << QStringLiteral(
"-2 people today-")
912 << QStringLiteral(
"-2 personnes aujourd'hui-")
915 QTest::newRow(
"safe-23")
916 << QStringLiteral(
"{% i18ncp 'The number of people who have visited "
917 "today' '%n people visited today' 1 %}")
919 "1 people visited today")
920 << QString::fromUtf8(
"1 personne a visité aujourd'hui") << dict;
922 QTest::newRow(
"safe-24")
923 << QStringLiteral(
"{% i18ncp 'The number of people who have visited "
924 "today' '%n people visited today' 2 %}")
925 << QStringLiteral(
"2 people visited today")
926 << QString::fromUtf8(
"2 personnes a visité aujourd'hui") << dict;
928 QTest::newRow(
"safe-25")
930 "{% autoescape off %}{% i18ncp 'The number of people who have "
931 "visited today' '%n people visited today' 1 %}{% endautoescape %}")
933 "1 people visited today")
934 << QString::fromUtf8(
"1 personne a visité aujourd'hui") << dict;
936 QTest::newRow(
"safe-26") << QStringLiteral(
937 "{% autoescape off %}{% i18ncp 'The number of people who have visited "
938 "today' '%n people visited today' 2 %}{% endautoescape %}")
939 << QStringLiteral(
"2 people visited today")
940 << QString::fromUtf8(
941 "2 personnes a visité aujourd'hui")
944 QTest::newRow(
"safe-27")
946 "{% i18ncp_var 'The number of people who have visited today' '%n "
947 "people visited today' 1 as num_people %}-{{ num_people }}-")
949 "-1 people visited today-")
950 << QString::fromUtf8(
"-1 personne a visité aujourd'hui-") << dict;
952 QTest::newRow(
"safe-28") << QStringLiteral(
953 "{% i18ncp_var 'The number of people who have visited today' '%n people "
954 "visited today' 2 as num_people %}-{{ num_people }}-")
955 << QStringLiteral(
"-2 people visited today-")
956 << QString::fromUtf8(
957 "-2 personnes a visité aujourd'hui-")
960 QTest::newRow(
"safe-29")
962 "{% autoescape off %}{% i18ncp_var 'The number of people who have "
963 "visited today' '%n people visited today' 1 as num_people %}-{{ "
964 "num_people }}-{% endautoescape %}")
966 "-1 people visited today-")
967 << QString::fromUtf8(
"-1 personne a visité aujourd'hui-") << dict;
969 QTest::newRow(
"safe-30") << QStringLiteral(
970 "{% autoescape off %}{% i18ncp_var 'The number of people who have "
971 "visited today' '%n people visited today' 2 as num_people %}-{{ "
972 "num_people }}-{% endautoescape %}")
973 << QStringLiteral(
"-2 people visited today-")
974 << QString::fromUtf8(
975 "-2 personnes a visité aujourd'hui-")
979 void TestInternationalization::testFailure()
983 auto t = m_engine->newTemplate(input,
QString());
984 QVERIFY(t->error() != NoError);
987 void TestInternationalization::testFailure_data()
989 QTest::addColumn<QString>(
"input");
991 QTest::newRow(
"fail-01") << QStringLiteral(
992 "{% i18np_var '%n people visited today' as num_people %}");
993 QTest::newRow(
"fail-02") << QStringLiteral(
994 "{% i18ncp_var 'The number of people who have visited today' '%n people "
995 "visited today' as num_people %}");
996 QTest::newRow(
"fail-03") << QStringLiteral(
997 "{% i18np '%n people visited today' %}");
998 QTest::newRow(
"fail-04") << QStringLiteral(
999 "{% i18ncp 'The number of people who have visited today' '%n people "
1000 "visited today' %}");
1003 void TestInternationalization::testDates()
1005 QFETCH(QDate, date);
1012 QCOMPARE(nullLocalizer->localizeDate(date), date.toString());
1013 QCOMPARE(cLocalizer->localizeDate(date), cDate);
1014 QCOMPARE(en_USLocalizer->localizeDate(date), en_USDate);
1015 QCOMPARE(en_GBLocalizer->localizeDate(date), en_GBDate);
1016 QCOMPARE(deLocalizer->localizeDate(date), deDate);
1017 QCOMPARE(frLocalizer->localizeDate(date), frDate);
1020 void TestInternationalization::testDates_data()
1022 QTest::addColumn<QDate>(
"date");
1023 QTest::addColumn<QString>(
"cDate");
1024 QTest::addColumn<QString>(
"en_USDate");
1025 QTest::addColumn<QString>(
"en_GBDate");
1026 QTest::addColumn<QString>(
"deDate");
1027 QTest::addColumn<QString>(
"frDate");
1029 QTest::newRow(
"date-01") << QDate(2010, 5, 9) << QStringLiteral(
"9 May 2010")
1030 << QStringLiteral(
"5/9/10")
1031 << QStringLiteral(
"09/05/2010")
1032 << QStringLiteral(
"09.05.10")
1033 << QStringLiteral(
"09/05/2010");
1035 QTest::newRow(
"date-02") << QDate(2010, 10, 11)
1036 << QStringLiteral(
"11 Oct 2010")
1037 << QStringLiteral(
"10/11/10")
1038 << QStringLiteral(
"11/10/2010")
1039 << QStringLiteral(
"11.10.10")
1040 << QStringLiteral(
"11/10/2010");
1043 void TestInternationalization::testIntegers()
1045 QFETCH(
int, integer);
1048 QFETCH(
QString, en_USInteger);
1049 QFETCH(
QString, en_GBInteger);
1053 QCOMPARE(nullLocalizer->localizeNumber(integer), nullInteger);
1054 QCOMPARE(cLocalizer->localizeNumber(integer), cInteger);
1055 QCOMPARE(en_USLocalizer->localizeNumber(integer), en_USInteger);
1056 QCOMPARE(en_GBLocalizer->localizeNumber(integer), en_GBInteger);
1057 QCOMPARE(deLocalizer->localizeNumber(integer), deInteger);
1058 QCOMPARE(frLocalizer->localizeNumber(integer), frInteger);
1061 void TestInternationalization::testIntegers_data()
1063 QTest::addColumn<int>(
"integer");
1064 QTest::addColumn<QString>(
"nullInteger");
1065 QTest::addColumn<QString>(
"cInteger");
1066 QTest::addColumn<QString>(
"en_USInteger");
1067 QTest::addColumn<QString>(
"en_GBInteger");
1068 QTest::addColumn<QString>(
"deInteger");
1069 QTest::addColumn<QString>(
"frInteger");
1071 QTest::newRow(
"integer-01")
1072 << 7 << QStringLiteral(
"7") << QStringLiteral(
"7") << QStringLiteral(
"7")
1073 << QStringLiteral(
"7") << QStringLiteral(
"7") << QStringLiteral(
"7");
1075 QTest::newRow(
"integer-02")
1076 << 7000 << QStringLiteral(
"7000") << QStringLiteral(
"7000")
1077 << QStringLiteral(
"7,000") << QStringLiteral(
"7,000")
1078 << QStringLiteral(
"7.000")
1079 << QString::fromUtf8(
"7" FR_THOUSAND_SEPARATOR
"000");
1082 void TestInternationalization::testFloats()
1084 QFETCH(qreal, floatingPoint);
1085 QFETCH(
QString, nullFloatingPoint);
1086 QFETCH(
QString, cFloatingPoint);
1087 QFETCH(
QString, en_USFloatingPoint);
1088 QFETCH(
QString, en_GBFloatingPoint);
1089 QFETCH(
QString, deFloatingPoint);
1090 QFETCH(
QString, frFloatingPoint);
1092 QCOMPARE(nullLocalizer->localizeNumber(floatingPoint), nullFloatingPoint);
1093 QCOMPARE(cLocalizer->localizeNumber(floatingPoint), cFloatingPoint);
1094 QCOMPARE(en_USLocalizer->localizeNumber(floatingPoint), en_USFloatingPoint);
1095 QCOMPARE(en_GBLocalizer->localizeNumber(floatingPoint), en_GBFloatingPoint);
1096 QCOMPARE(deLocalizer->localizeNumber(floatingPoint), deFloatingPoint);
1097 QCOMPARE(frLocalizer->localizeNumber(floatingPoint), frFloatingPoint);
1100 void TestInternationalization::testFloats_data()
1102 QTest::addColumn<qreal>(
"floatingPoint");
1103 QTest::addColumn<QString>(
"nullFloatingPoint");
1104 QTest::addColumn<QString>(
"cFloatingPoint");
1105 QTest::addColumn<QString>(
"en_USFloatingPoint");
1106 QTest::addColumn<QString>(
"en_GBFloatingPoint");
1107 QTest::addColumn<QString>(
"deFloatingPoint");
1108 QTest::addColumn<QString>(
"frFloatingPoint");
1110 QTest::newRow(
"float-01")
1111 << qreal(7.4) << QStringLiteral(
"7.4") << QStringLiteral(
"7.40")
1112 << QStringLiteral(
"7.40") << QStringLiteral(
"7.40")
1113 << QStringLiteral(
"7,40") << QStringLiteral(
"7,40");
1116 void TestInternationalization::testTimes()
1118 QFETCH(QTime, time);
1126 QCOMPARE(nullLocalizer->localizeTime(time), nullTime);
1127 QCOMPARE(cLocalizer->localizeTime(time), cTime);
1128 QCOMPARE(en_USLocalizer->localizeTime(time), en_USTime);
1129 QCOMPARE(en_GBLocalizer->localizeTime(time), en_GBTime);
1130 QCOMPARE(deLocalizer->localizeTime(time), deTime);
1131 QCOMPARE(frLocalizer->localizeTime(time), frTime);
1134 void TestInternationalization::testTimes_data()
1136 QTest::addColumn<QTime>(
"time");
1137 QTest::addColumn<QString>(
"nullTime");
1138 QTest::addColumn<QString>(
"cTime");
1139 QTest::addColumn<QString>(
"en_USTime");
1140 QTest::addColumn<QString>(
"en_GBTime");
1141 QTest::addColumn<QString>(
"deTime");
1142 QTest::addColumn<QString>(
"frTime");
1144 QTest::newRow(
"time-01") << QTime(5, 6, 7) << QStringLiteral(
"05:06:07")
1145 << QStringLiteral(
"05:06:07")
1146 << QStringLiteral(
"5:06 AM")
1147 << QStringLiteral(
"05:06") << QStringLiteral(
"05:06")
1148 << QStringLiteral(
"05:06");
1150 QTest::newRow(
"time-02") << QTime(11, 12, 13) << QStringLiteral(
"11:12:13")
1151 << QStringLiteral(
"11:12:13")
1152 << QStringLiteral(
"11:12 AM")
1153 << QStringLiteral(
"11:12") << QStringLiteral(
"11:12")
1154 << QStringLiteral(
"11:12");
1156 QTest::newRow(
"time-03") << QTime(15, 12, 13) << QStringLiteral(
"15:12:13")
1157 << QStringLiteral(
"15:12:13")
1158 << QStringLiteral(
"3:12 PM")
1159 << QStringLiteral(
"15:12") << QStringLiteral(
"15:12")
1160 << QStringLiteral(
"15:12");
1163 void TestInternationalization::testDateTimes()
1165 QFETCH(QDateTime, dateTime);
1167 QFETCH(
QString, en_USDateTime);
1168 QFETCH(
QString, en_GBDateTime);
1172 QCOMPARE(nullLocalizer->localizeDateTime(dateTime), dateTime.toString());
1173 QCOMPARE(cLocalizer->localizeDateTime(dateTime), cDateTime);
1174 QCOMPARE(en_USLocalizer->localizeDateTime(dateTime), en_USDateTime);
1175 QCOMPARE(en_GBLocalizer->localizeDateTime(dateTime), en_GBDateTime);
1176 QCOMPARE(deLocalizer->localizeDateTime(dateTime), deDateTime);
1177 QCOMPARE(frLocalizer->localizeDateTime(dateTime), frDateTime);
1180 void TestInternationalization::testDateTimes_data()
1182 QTest::addColumn<QDateTime>(
"dateTime");
1183 QTest::addColumn<QString>(
"cDateTime");
1184 QTest::addColumn<QString>(
"en_USDateTime");
1185 QTest::addColumn<QString>(
"en_GBDateTime");
1186 QTest::addColumn<QString>(
"deDateTime");
1187 QTest::addColumn<QString>(
"frDateTime");
1189 QTest::newRow(
"datetime-01")
1190 << QDateTime(QDate(2005, 6, 7), QTime(5, 6, 7))
1191 << QStringLiteral(
"7 Jun 2005 05:06:07")
1192 << QStringLiteral(
"6/7/05 5:06 AM") << QStringLiteral(
"07/06/2005 05:06")
1193 << QStringLiteral(
"07.06.05 05:06") << QStringLiteral(
"07/06/2005 05:06");
1195 QTest::newRow(
"datetime-02")
1196 << QDateTime(QDate(2005, 6, 7), QTime(11, 12, 13))
1197 << QStringLiteral(
"7 Jun 2005 11:12:13")
1198 << QStringLiteral(
"6/7/05 11:12 AM") << QStringLiteral(
"07/06/2005 11:12")
1199 << QStringLiteral(
"07.06.05 11:12") << QStringLiteral(
"07/06/2005 11:12");
1201 QTest::newRow(
"datetime-03")
1202 << QDateTime(QDate(2005, 6, 7), QTime(15, 12, 13))
1203 << QStringLiteral(
"7 Jun 2005 15:12:13")
1204 << QStringLiteral(
"6/7/05 3:12 PM") << QStringLiteral(
"07/06/2005 15:12")
1205 << QStringLiteral(
"07.06.05 15:12") << QStringLiteral(
"07/06/2005 15:12");
1207 QTest::newRow(
"datetime-04")
1208 << QDateTime(QDate(2005, 10, 11), QTime(5, 6, 7))
1209 << QStringLiteral(
"11 Oct 2005 05:06:07")
1210 << QStringLiteral(
"10/11/05 5:06 AM")
1211 << QStringLiteral(
"11/10/2005 05:06") << QStringLiteral(
"11.10.05 05:06")
1212 << QStringLiteral(
"11/10/2005 05:06");
1214 QTest::newRow(
"datetime-05")
1215 << QDateTime(QDate(2005, 10, 11), QTime(11, 12, 13))
1216 << QStringLiteral(
"11 Oct 2005 11:12:13")
1217 << QStringLiteral(
"10/11/05 11:12 AM")
1218 << QStringLiteral(
"11/10/2005 11:12") << QStringLiteral(
"11.10.05 11:12")
1219 << QStringLiteral(
"11/10/2005 11:12");
1221 QTest::newRow(
"datetime-06")
1222 << QDateTime(QDate(2005, 10, 11), QTime(15, 12, 13))
1223 << QStringLiteral(
"11 Oct 2005 15:12:13")
1224 << QStringLiteral(
"10/11/05 3:12 PM")
1225 << QStringLiteral(
"11/10/2005 15:12") << QStringLiteral(
"11.10.05 15:12")
1226 << QStringLiteral(
"11/10/2005 15:12");
1230 #include "testinternationalization.moc"
The Context class holds the context to render a Template with.
std::shared_ptr< AbstractLocalizer > localizer() const
void setLocalizer(std::shared_ptr< AbstractLocalizer > localizer)
Cutelee::Engine is the main entry point for creating Cutelee Templates.
Provides internationalization based on QLocale and QTranslator.
The Cutelee namespace holds all public Cutelee API.
Cutelee::SafeString markSafe(const Cutelee::SafeString &input)
Utility functions used throughout Cutelee.