<table><tr><td style="">habacker added a comment.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D14779">View Revision</a></tr></table><br /><div><div><p>With the drawback that the qm file need to be generated on each build and the po file needs to be updated on any translations change in the test  app</p>

<p>BTW: I tried your approach by</p>

<ol class="remarkup-list">
<li class="remarkup-list-item">downloaded po file from <a href="https://websvn.kde.org/trunk/l10n-kf5/en/messages/frameworks/kcoreaddons5_qt.po?revision=1522662&view=markup" class="remarkup-link" target="_blank" rel="noreferrer">https://websvn.kde.org/trunk/l10n-kf5/en/messages/frameworks/kcoreaddons5_qt.po?revision=1522662&view=markup</a></li>
<li class="remarkup-list-item">did run lrelease on that file and placed it into kcoreaddons source dir as kcoreaddons5_qt.qm</li>
<li class="remarkup-list-item">added to top level CMakelists.txt</li>
</ol>

<p><tt style="background: #ebebeb; font-size: 13px;">add_definitions(-DCMAKE_SOURCE_DIR="${CMAKE_SOURCE_DIR}")</tt></p>

<ol class="remarkup-list" start="3">
<li class="remarkup-list-item">add to autotests/kformattest.cpp</li>
</ol>

<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">void KFormatTest::initTestCase()
{
    QLocale::setDefault(QLocale::C);
    QTranslator *l = new QTranslator();
    l->load(QStringLiteral(CMAKE_SOURCE_DIR "/kcoreaddons5_qt.qm"));
    QCoreApplication::installTranslator(l);
}</pre></div>

<p>without kcoreaddons-lang package installed the test case returns on a system with installed de_DE</p>

<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">strace -e trace=file bin/kformattest  2>&1 | grep \.qm
...
access("/home/xxx/src/kf5/kcoreaddons/kcoreaddons5_qt.qm", R_OK) = 0
stat("/home/xxx/src/kf5/kcoreaddons/kcoreaddons5_qt.qm", {st_mode=S_IFREG|0644, st_size=729, ...}) = 0
open("/home/xxx/src/kf5/kcoreaddons/kcoreaddons5_qt.qm", O_RDONLY|O_CLOEXEC) = 5</pre></div>



<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">~/src/kf5/kcoreaddons-build> bin/kformattest 
********* Start testing of KFormatTest *********
Config: Using QtTest library 5.11.1, Qt 5.11.1 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 4.8.5)
PASS   : KFormatTest::initTestCase()
PASS   : KFormatTest::formatByteSize()
PASS   : KFormatTest::formatDuration()
FAIL!  : KFormatTest::formatDecimalDuration() Compared values are not the same
   Actual   (format.formatDecimalDuration(10))   : "10 milliseconds"
   Expected (QStringLiteral("10 millisecond(s)")): "10 millisecond(s)"
   Loc: [/home/xxx/src/kf5/kcoreaddons/autotests/kformattest.cpp(302)]
FAIL!  : KFormatTest::formatSpelloutDuration() Compared values are not the same
   Actual   (format.formatSpelloutDuration(1000)): "1 second"
   Expected (QStringLiteral("1 second(s)"))      : "1 second(s)"
   Loc: [/home/xxx/src/kf5/kcoreaddons/autotests/kformattest.cpp(318)]
PASS   : KFormatTest::formatRelativeDate()
PASS   : KFormatTest::formatValue()
PASS   : KFormatTest::cleanupTestCase()
Totals: 6 passed, 2 failed, 0 skipped, 0 blacklisted, 1ms
********* Finished testing of KFormatTest *********</pre></div>

<p>with installed kcoreaddons-lang</p>

<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">~/src/kf5/kcoreaddons-build> strace -e trace=file bin/kformattest  2>&1 | grep \.qm
access("/usr/share/locale/en/LC_MESSAGES/kcoreaddons5_qt.qm", R_OK) = 0
open("/usr/share/locale/en/LC_MESSAGES/kcoreaddons5_qt.qm", O_RDONLY|O_CLOEXEC) = 5
access("/usr/share/locale/de/LC_MESSAGES/kcoreaddons5_qt.qm", R_OK) = 0
open("/usr/share/locale/de/LC_MESSAGES/kcoreaddons5_qt.qm", O_RDONLY|O_CLOEXEC) = 5
access("/home/xxx/src/kf5/kcoreaddons/kcoreaddons5_qt.qm", R_OK) = 0
stat("/home/xxx/src/kf5/kcoreaddons/kcoreaddons5_qt.qm", {st_mode=S_IFREG|0644, st_size=729, ...}) = 0
open("/home/xxx/src/kf5/kcoreaddons/kcoreaddons5_qt.qm", O_RDONLY|O_CLOEXEC) = 5

```~/src/kf5/kcoreaddons-build> bin/kformattest 
********* Start testing of KFormatTest *********
Config: Using QtTest library 5.11.1, Qt 5.11.1 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 4.8.5)
PASS   : KFormatTest::initTestCase()
PASS   : KFormatTest::formatByteSize()
FAIL!  : KFormatTest::formatDuration() Compared values are not the same
   Actual   (format.formatDuration(singleSecond, options)): "0 h 00 m 04 s"
   Expected (QStringLiteral("0h00m04s"))                  : "0h00m04s"
   Loc: [/home/xxx/src/kf5/kcoreaddons/autotests/kformattest.cpp(226)]
FAIL!  : KFormatTest::formatDecimalDuration() Compared values are not the same
   Actual   (format.formatDecimalDuration(10))   : "10 milliseconds"
   Expected (QStringLiteral("10 millisecond(s)")): "10 millisecond(s)"
   Loc: [/home/xxx/src/kf5/kcoreaddons/autotests/kformattest.cpp(302)]
FAIL!  : KFormatTest::formatSpelloutDuration() Compared values are not the same
   Actual   (format.formatSpelloutDuration(1000)): "1 second"
   Expected (QStringLiteral("1 second(s)"))      : "1 second(s)"
   Loc: [/home/xxx/src/kf5/kcoreaddons/autotests/kformattest.cpp(318)]
FAIL!  : KFormatTest::formatRelativeDate() Compared values are not the same
   Actual   (format.formatRelativeDate(testDate, QLocale::LongFormat)): "Heute"
   Expected (QStringLiteral("Today"))                                 : "Today"
   Loc: [/home/xxx/src/kf5/kcoreaddons/autotests/kformattest.cpp(341)]
PASS   : KFormatTest::formatValue()
PASS   : KFormatTest::cleanupTestCase()
Totals: 4 passed, 4 failed, 0 skipped, 0 blacklisted, 1ms
********* Finished testing of KFormatTest *********

Seems not to work without further changes 

What is the drawback to not load any translation in the ECM qm file loader with using QLocale::C as default locale ?</pre></div></div></div><br /><div><strong>REPOSITORY</strong><div><div>R244 KCoreAddons</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D14779">https://phabricator.kde.org/D14779</a></div></div><br /><div><strong>To: </strong>habacker, Frameworks<br /><strong>Cc: </strong>aacid, kde-frameworks-devel, michaelh, ngraham, bruns<br /></div>