<table><tr><td style="">aacid 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><blockquote style="border-left: 3px solid #8C98B8;
          color: #6B748C;
          font-style: italic;
          margin: 4px 0 12px 0;
          padding: 8px 12px;
          background-color: #F8F9FC;">
<div style="font-style: normal;
          padding-bottom: 4px;">In <a href="https://phabricator.kde.org/D14779#309943" style="background-color: #e7e7e7;
          border-color: #e7e7e7;
          border-radius: 3px;
          padding: 0 4px;
          font-weight: bold;
          color: black;text-decoration: none;">D14779#309943</a>, <a href="https://phabricator.kde.org/p/habacker/" style="
              border-color: #f1f7ff;
              color: #19558d;
              background-color: #f1f7ff;
                border: 1px solid transparent;
                border-radius: 3px;
                font-weight: bold;
                padding: 0 4px;">@habacker</a> wrote:</div>
<div style="margin: 0;
          padding: 0;
          border: 0;
          color: rgb(107, 116, 140);"><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
<br /><br />
<tt style="background: #ebebeb; font-size: 13px;">add_definitions(-DCMAKE_SOURCE_DIR="${CMAKE_SOURCE_DIR}")</tt></li>
<li class="remarkup-list-item">add to autotests/kformattest.cpp
<br /><br />
<tt style="background: #ebebeb; font-size: 13px;">`</tt>void KFormatTest::initTestCase() { QLocale::setDefault(QLocale::C); QTranslator *l = new QTranslator(); l->load(QStringLiteral(CMAKE_SOURCE_DIR "/kcoreaddons5_qt.qm")); QCoreApplication::installTranslator(l); } <tt style="background: #ebebeb; font-size: 13px;">`</tt> without kcoreaddons-lang package installed the test case returns on a system with installed de_DE
<br /><br />
<tt style="background: #ebebeb; font-size: 13px;">`</tt>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 <tt style="background: #ebebeb; font-size: 13px;">`</tt>
<br /><br />
<tt style="background: #ebebeb; font-size: 13px;">`</tt>~/src/kf5/kcoreaddons-build> bin/kformattest<ul class="remarkup-list">
<li class="remarkup-list-item">Start testing of KFormatTest <strong>*</strong>**** 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</li>
<li class="remarkup-list-item">Finished testing of KFormatTest <strong>*</strong>**** <tt style="background: #ebebeb; font-size: 13px;">`</tt> with installed kcoreaddons-lang
<br /><br />
<tt style="background: #ebebeb; font-size: 13px;">`</tt>~/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
<br /><br />
<tt style="background: #ebebeb; font-size: 13px;">`</tt>~/src/kf5/kcoreaddons-build> bin/kformattest</li>
<li class="remarkup-list-item">Start testing of KFormatTest <strong>*</strong>**** 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</li>
<li class="remarkup-list-item">Finished testing of KFormatTest <strong>*</strong>****
<br /><br />
Seems not to work without further changes</li>
</ul></li>
</ol></div>
</blockquote>

<p>The failures were expected, which is very weird is that you're getting different failures, i.e you're still getting Heute instead of Today even if you set the locale to C.</p>

<p>Did you have that problem when you made ecm not create a translator?</p>

<blockquote style="border-left: 3px solid #a7b5bf; color: #464c5c; font-style: italic; margin: 4px 0 12px 0; padding: 4px 12px; background-color: #f8f9fc;"><p>What is the drawback to not load any translation in the ECM qm file loader with using QLocale::C as default locale ?</p></blockquote>

<p>I've seen some systems that default to C locale, and I would prefer them to still have the english translation working.</p>

<p>Cheers,</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);">Albert</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>