add test case for qrc translations

pull/9239/head
Eli Schwartz 3 years ago
parent d2bf77342e
commit ad3bf77ff0
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 9
      test cases/frameworks/4 qt/main.cpp
  2. 6
      test cases/frameworks/4 qt/meson.build
  3. 6
      test cases/frameworks/4 qt/qt4_lang.qrc
  4. 12
      test cases/frameworks/4 qt/qt4embedded_fr.ts
  5. 6
      test cases/frameworks/4 qt/qt5_lang.qrc
  6. 12
      test cases/frameworks/4 qt/qt5embedded_fr.ts

@ -1,4 +1,6 @@
#include <QApplication>
#include <QTranslator>
#include <QDebug>
#include "mainWindow.h"
#if QT_VERSION > 0x050000
@ -16,6 +18,13 @@ int main(int argc, char **argv) {
Q_INIT_RESOURCE(stuff2);
#endif
QApplication app(argc, argv);
auto *translator = new QTranslator;
if (translator->load(QLocale(), QT "embedded", "_", ":/lang"))
qApp->installTranslator(translator);
qDebug() << QObject::tr("Translate me!");
MainWindow *win = new MainWindow();
QImage qi(":/thing.png");
if(qi.width() != 640) {

@ -81,10 +81,16 @@ foreach qt : ['qt4', 'qt5', 'qt6']
# qt4-rcc and qt5-rcc take different arguments, for example qt4: ['-compress', '3']; qt5: '--compress=3'
qtmodule.preprocess(qt + 'testrccarg', qresources : files(['stuff.qrc', 'stuff2.qrc']), rcc_extra_arguments : '--compress=3', method : get_option('method'))
translations_cpp = qtmodule.compile_translations(qresource: qt+'_lang.qrc')
# unity builds suck and definitely cannot handle two qrc embeds in one compilation unit
unityproof_translations = static_library('unityproof_translations', translations_cpp)
extra_cpp_args += '-DQT="@0@"'.format(qt)
qexe = executable(qt + 'app',
sources : ['main.cpp', 'mainWindow.cpp', # Sources that don't need preprocessing.
prep, prep_rcc],
dependencies : qtdep,
link_with: unityproof_translations,
cpp_args: extra_cpp_args,
gui_app : true)

@ -0,0 +1,6 @@
<RCC>
<qresource prefix="/lang">
<file>qt4embedded_fr.qm</file>
</qresource>
</RCC>

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0" language="fr_FR">
<context>
<name>QObject</name>
<message>
<location filename="q5core.cpp" line="23"/>
<source>Translate me!</source>
<translation>Traduisez moi!</translation>
</message>
</context>
</TS>

@ -0,0 +1,6 @@
<RCC>
<qresource prefix="/lang">
<file>qt5embedded_fr.qm</file>
</qresource>
</RCC>

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="fr_FR">
<context>
<name>QObject</name>
<message>
<location filename="q5core.cpp" line="23"/>
<source>Translate me!</source>
<translation>Traduisez moi!</translation>
</message>
</context>
</TS>
Loading…
Cancel
Save